tags:

views:

71

answers:

1

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.

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?

+3  A: 

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.

Marek
You are right. I found another bug in my code (other places) and that's reason to cause the issue. File.Copy() is OK to release the files. Thanks!
David.Chu.ca