File.Copy() sync or asycn?
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);
UnMa开发者_C百科pDrive(); // 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.
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?
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.
精彩评论