CopyFile 是否对源文件设置了任何锁定? [英] Does CopyFile place any lock on the source file?
问题描述
当我使用 CopyFile
,源文件会以任何方式被锁定吗?比如说——如果复制操作开始,然后有人想打开源文件,会成功吗?如果某人"请求独占访问文件,他的 Win32 API 调用(可能是 CreateFile
) 失败,还是会等待(或其他)直到复制操作完成?
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?
推荐答案
如果有人请求独占访问已打开的文件,该请求将失败.Windows 没有包含以下内容的文件打开模式:如果其他人正在使用该文件,请将其关闭."
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."
我记得,CopyFile
打开源文件,以便其他人可以读取,但不能写入.
As I recall, CopyFile
opens the source file so that others can read, but not write it.
这篇关于CopyFile 是否对源文件设置了任何锁定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!