file renaming problem?

早过忘川 提交于 2019-12-05 04:50:55

You don't need to call the File.Delete as part of the rename, you would have needed it if you did a copy.

Try using the FileShare enumerator. Then try to open a file with monesharing, close the handle and if there is no exception you can move the file.

http://msdn.microsoft.com/de-de/library/system.io.fileshare.aspx

It contains the methods Read, Write etc.

Create a FileInfo instance, in which you can rename it more than once.

FileInfo file = new FileInfo(source);
file.MoveTo(destination);

// execute more code

file.MoveTo(destination2)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!