On Fri, 14 Jun 2024 09:34:56 +0200, R.Wieser wrote:
Use the FILE_SHARE_DELETE sharing flag.
I tried that with both the copy as well as the move.
The move does actually works, but the moved file (ofcourse?) disappears when the file-handle gets closed.
I forgot to mention that, if the file is moved, if it's moved to a different drive, any data writtin into the file after the file was moved, will not be applied to the moved file. e.g.:
1. An application create and overwrite a file (i.e. start from scratch)
using the needed flags: c:\temp\test.txt
2. The application display a message box to pause the application.
3. From outside of the application, move the file and optionally change the file name.
4. Close the message box to resume application.
5. The application write something into the file, then terminates.
If the file was moved to the same drive, the moved file will have the
written data.
If the file was moved to a different drive, the moved file will stay empty
and not have the written data.
I think that's the limitation of the FILE_SHARE_DELETE flag. Since it
controls whether the directory entry for the file can be modified or not. Moving the file to a different drive would be a copy of the directory entry, instead of modifying the existing one.
When I try a copy I got the "in use" error every time, no matter what attributes I created the temp file with.
That would require FILE_SHARE_READ, and without FILE_FLAG_DELETE_ON_CLOSE.
FILE_FLAG_DELETE_ON_CLOSE description says:
"Subsequent open requests for the file fail, unless the FILE_SHARE_DELETE
share mode is specified."
Using both FILE_FLAG_DELETE_ON_CLOSE and FILE_SHARE_DELETE, but without FILE_SHARE_READ allows file to be opened, but does not allow the file to be read.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)