Lobuno
Lobuno

Reputation: 1405

CopyFileEx and partially locked files

I have been using CopyFileEx since the beginning of times and it has been working great. If the file is not locked, it will copy the file. If the file is locked, it will not and GetLastError will report the error. All fine and dandy.

However, there are some files that are partially locked, PST outlook files being the best example. In that case, CopyFileEx begins to copy, and when it hits the part of the file that is locked, it will hang and never return back (on Windows 7, maybe on other systems too).

Is there any way to avoid this problem?

Upvotes: 4

Views: 969

Answers (2)

Brian R. Bondy
Brian R. Bondy

Reputation: 347216

There is a way to avoid it, but there is no easy solution. Please see my answer here.

Upvotes: 2

Jerry Coffin
Jerry Coffin

Reputation: 490108

You could do the copying yourself, starting with a call to LockFileEx. It has a flag to fail immediately if it can't lock what you've asked it to.

Upvotes: 2

Related Questions