CopyFileEx and partially blocked files

I have been using CopyFileEx from the start and it works great. If the file is not locked, it will copy the file. If the file is locked, it will not be, and GetLastError will report an error. All beautiful and dandy.

However, there are some files that are partially blocked, and the best PST files are the best example. In this case, CopyFileEx starts to copy, and when it gets to part of the locked file, it will freeze and never return (in Windows 7, possibly in other systems).

Is there any way to avoid this problem?

+4
source share
2 answers

There is a way to avoid this, but there is no easy solution. See mine here .

+2
source

You can copy yourself, starting with a call to LockFileEx . He has a flag that immediately crashes if he cannot block what you requested.

+2
source

Source: https://habr.com/ru/post/1302240/


All Articles