When renaming a folder in C#, System.IO.Directory.Move
throws System.IO.IOException
(message \"access denied\") if that folder or any subfolder is curr
I had the same problem. As soon as I had an explorer window open and once navigated into the folder to rename, the Directory.Move
failed with a "access denied" (Windows 7 Professional 64bit, application compiled as x86).
Interestingly, the command Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory(...)
succeeds to move the contents to a new directory, it only fails to delete the old directory if you are staying inside a subfolder of the directory to move. This can be fixed by catching the exception that is thrown on the first error and try again a second time. Now the source folder is also removed.