C# 的 Directory.Move System.NotSupportedException
有没有办法绕过问题标题中指定的异常?我完全不知道该怎么做,我需要更改很多目录的目录名称,并且对其进行编程会快得多,但是这个异常让我感到非常头疼......代码并不复杂,除了一行代码之外,一切正常:
Directory.Move(folderName, path + "\\" + novoIme);
提前感谢您的任何帮助:)
Is there a way to bypass the exception as named in the question title? I have absolutely no idea what to do, I need to change the directory names for a whole lot of directories and it would be much faster to programme it, but this exception has cause me some serious headaches... The code isn't complicated, everything works fine except that one line of code:
Directory.Move(folderName, path + "\\" + novoIme);
Thanks in advance for any sort of help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许源路径和目标路径位于不同的卷上?
Directory.Move
方法不支持跨成交量移动。您必须实现自己的例程才能执行此操作,或者使用其他人的例程。 FolderMove on CodePlex 出现在我的搜索结果中。
Perhaps the source and destination paths are on different volumes?
Directory.Move
method does not support cross-volume moves.You will have to implement your own routine to do this, or use someone else's. FolderMove on CodePlex comes up in my search results.
您可以将
Microsoft.VisualBasic
引用添加到您的项目中,并使用以下代码重命名目录:You can add
Microsoft.VisualBasic
reference to your project and use this code to rename the directory:如果您确定源文件夹存在,请尝试使用提升的权限运行应用程序,看看会发生什么。另外,尝试在单独的变量中形成目标路径,将其添加到“监视”窗口,然后查看是否创建了正确的名称。
If you are certain that source folder exists, try running your application with elevated privileges and see what happens. Also, try forming the destination path in a separate variable, add it to Watches window and see whether the correct name is created.