Weird System.IO Related Problems
-
I am having what appears to be a strange problem when I do File and or directory management using System.IO. For example if I have the following lines of code: Directory.Delete() File.Copy() Use the File If the directory to be deleted is very large, it appears that while the directory is being deleted, the code jumps to the next line which is copy a file and the following line which is use the File. But since the directory deletion is not complete the File Copy or use hte file fails. I cannot reproduce the problem in debug mode so am not sure what the hell is happening. Have also noticed the problem when I was doing server maintenance and was deleting a few gigs of files manually. At the same time I was running my code that was writing files to the drive. Since the drive was busy it was taking time to write the files. What was strange is that it attempted to use the file before it finished writing it. Which is the same problem as I mentioned above. It seems to jump over a line of code to the next without completeing teh first, implying that the File IO is asynchronous or that something else is very evil in there :-) Is Directory.delete asynchronous? Is there a global setting that makes it asynchronous? Any ideas? Thanks.