File.Copy()同步或asycn?File、Copy、asycn

由网友(滿身驕傲)分享简介:我使用File.Copy(来源,DEST,真)从本地复制文件的远程使用覆盖选项。在我的情况下,dest为映射网络驱动器:I am using File.Copy(source, dest, true) to copy a file from local to remote with overwrite option....

我使用File.Copy(来源,DEST,真)从本地复制文件的远程使用覆盖选项。在我的情况下,dest为映射网络驱动器:

I am using File.Copy(source, dest, true) to copy a file from local to remote with overwrite option. In my case, the dest is a mapped network drive:

File.Copy(source, dest, true);
UnMapDrive(); // unmap the network drive

我的问题之后的是源文件可能被锁定,这样我可以不删除本地文件。

The problem I have afterward is that the source file may be locked so that I could not delete the file from local.

我想,这可能是由File.Copy()调用引起的。不知道这一个同步进程中。换句话说,就是在调用之后发布的源文件?

I guess that it might be caused by File.Copy() call. Not sure if this one is synced process or not. In other words, is the source file released after the call?

推荐答案

是的,它被释放,File.Copy方法阻止执行,直到复制操作完成。

Yes, it is released and the File.Copy method blocks the execution until the copy operation completes.

该文件可能是可用于读取,但锁定为删除。

The file may be available for read but locked for deletion.

请与进程监视器哪个进程锁定的源文件。

Check with Process Monitor which process is locking the source file.

阅读全文

相关推荐

最新文章