Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文件的句柄,它被打开了。
HANDLE h = ::CreateFile(...)
我想复制这个文件。怎么做?我想做这样的事情:
CopyFile(h, "new_file.dat");
我知道有CopyFile(fileName, newFileName)函数,但在使用这个调用这个函数之前,我似乎必须关闭我的句柄。有没有其他的复制方式?
CopyFile(fileName, newFileName)
我猜你在windows下工作。问题是,在 Windows 中,当您打开文件时,默认情况下会阻止其他打开(复制也会打开文件)。据我所知, CreateFile 有一个标志,允许以共享模式打开文件。根据定义,该标志应该可以解决您的问题。