I get an exception when trying to rename a folder with this code:
Directory.Move(@"D:\MyOldFolderName", @"D:\MyNewFolderName");
An 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 fact is that the EXACT code line works in a different class of my application. An application consists of only one DLL.
What's going on here? Any ideas?
Additional Information:
- The application is a WPF application using the MVVM design pattern.
- The class in which the folder is renamed. Works with ViewModel.
- The class in which the folder is renamed DOES NOT work, this is a helper class (the method uses some databases before trying to rename folders).
source
share