Is this normal behavior of copyfile?
Yes, this is normal. FPC CopyFile opens the sourcefile with fmOpenRead or fmShareDenyWrite.
The fmShareDenyWrite prevents the writing of the file during the copy process.
From windows I can still normally copy the file with copy/paste.
Yes, but you can get a corrupt file if the file is written during the copy process. Unless Windows uses a shadow copy (in which case you have an old version).
Any other suggestion?
You could try the Windows api directly.
uses Windows;
procedure myCopyFile(SourcePathname, DestPathname: string);
var
SourceArray, DestArray: array [0 .. 255] of Char; // Max length of path set at 80 chars
begin // Doesn't support wildcards
StrPCopy(SourceArray, SourcePathname);
StrPCopy(DestArray, DestPathname);
Windows.CopyFile(SourceArray, DestArray, false); // Copies files even with 0 bytes
end;
Another option (if Windows.CopyFile doesn't work) is to try SHFileOperation().