I get an exception when trying the rename a folder with this code:
Directory.Move(@"D:\MyOldFolderName", @"D:\MyNewFolderName");
The exception:
System.IO.IOException was unhandled
Message="Access to the path 'D:\\MyOldFolderName' is denied."
Source="mscorlib"
StackTrace:
at System.IO.Directory.Move(String sourceDirName, String destDirName)
...
The thing is, the EXACT same codeline works in another class of my application. The application only consist of one single DLL.
What is happening here? Any ideas?
More info:
- The application is a WPF application, using the MVVM design pattern.
- The class where the folder rename DOES work is a ViewModel.
- The class where the folder rename does NOT work is a helper class (the method does some database related stuff before trying to rename the folder).