File.Copy()同步或asycn? [英] File.Copy() sync or asycn?

查看:214
本文介绍了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. 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.

这篇关于File.Copy()同步或asycn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆