When I copy a file with CopyFile, will the source file be locked in any way? Say - if the copy operation starts, and then someone wants to open the source file, will it succeed? What if the "someone" requests exclusive access to the file, will his Win32 API call (probably a CreateFile) fail, or will it wait (or whatever) until the copy operation is done?

有帮助吗?

解决方案

If somebody requests exclusive access to a file that's already opened, that request will fail. Windows does not have a file open mode that consists of, "If somebody else is using the file, bump him off."

As I recall, CopyFile opens the source file so that others can read, but not write it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top