I am encountering a strange issue: I call a WCF-Operation from my client. The operation deletes all files in a specified directory and finally deletes their parent directory too.
ACtually, this works. No exception is thrown and the files within the folder and the folder itself are deleted successfully.
But: the wcf context of my client gets invalidated so I need to instantiate the Service Client again. If I do not delete the directory but only the files within everything works fine. Actually I do not have any clue why deleting a directory has an impact on the Client calling the service ??!
Thank You
Sorry for the late reply, but I just wasted an afternoon dealing with the exact same issue. I finally tracked down the issue to the call to Directory.Delete(). It was working fine, no exceptions etc.
In our case we were deleting a subfolder of the folder that hosted the WCF service. From what I understand, this forces the application to recycle, killing your session/service etc
Our service was storing/deleting files, so we moved the file storage location to outside of the applications folder and it now seems to work fine.
More info here:
http://www.geekays.net/post/2008/10/14/ASPNET-webdomain-recycle-on-subfolder-changes.aspx