我正在尝试移动 (File.Move) 锁定的 .dll 文件以执行应用程序更新。 File.Move 方法无一异常(exception)地执行。但是文件没有移动。我的意思是在执行 File.Move 方法后,我有同一个文件的两个副本:在目标文件夹和源文件夹中。这是代码:)
File.Move(fileName, newFileName);
谁能解释一下这是什么原因?
请您参考如下方法:
File.Move across volumes 按顺序执行两个操作:
- 文件复制
- 文件删除
似乎第一个成功了,第二个默默地失败了。结果符合预期。
此处注释:http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx
If you try to move a file across disk volumes and that file is in use, the file is copied to the destination but not deleted from the source.
