Directory.Move(): Access to Path is Denied

Thank you all for the replies and help. I have figured out what the issue was.

It is because there was a file that's not completely closed.

I was checking the files that were generated, and missed the files the program was reading from.

All files that were generated were closed completely. It was one file I used StreamReader to open but didn't close. I modified the code and am now not having problem, so I figure that's were the issue was.

Thanks for all the comments and answers, that definitely help me with thinking and figuring out the problem.


See http://windowsxp.mvps.org/processlock.htm

Sometimes, you try to move or delete a file or folder and receive access violation or file in use - errors. To successfully delete a file, you will need to identify the process which has locked the file. You need to exit the process first and then delete the particular file. To know which process has locked a file, you may use one of the methods discussed in this article.

Using Process Explorer - download from http://download.sysinternals.com/files/ProcessExplorer.zip

Process Explorer shows you information about which handles and DLLs processes have opened or loaded.

Download Process Explorer from Microsoft site and run the program. Click the Find menu, and choose Find Handle or DLL... Type the file name (name of the file which is locked by some process.) After typing the search phrase, click the Search button You should see the list of applications which are accessing the file.