Neal Hartman
asked on
MoveFileEx
If OrigionalFile is open, this works fine:
MoveFileEx(NewFile, OrigionalFile, MOVEFILE_DELAY_UNTIL_REBOO T + MOVEFILE_REPLACE_EXISTING)
But if OrigionalFile is open AND the file properties are set to ReadOnly the above command does not work. How can I replace OrigionalFile under thses conditions?
Thanks!
MoveFileEx(NewFile, OrigionalFile, MOVEFILE_DELAY_UNTIL_REBOO
But if OrigionalFile is open AND the file properties are set to ReadOnly the above command does not work. How can I replace OrigionalFile under thses conditions?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Because:
MOVEFILE_DELAY_UNTIL_REBOO T
Windows NT only: The function does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
MOVEFILE_DELAY_UNTIL_REBOO
Windows NT only: The function does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
How can I replace OrigionalFile under thses conditions?
========================== ==========
how can temporary make the orginal file writable( remove read only flag) using filesystemobject
and then set it back to read only.
But if for security reasons (permissions) that is not possible then consider copying the file to another file
and then use the copy of the file (which is not read only)
==========================
how can temporary make the orginal file writable( remove read only flag) using filesystemobject
and then set it back to read only.
But if for security reasons (permissions) that is not possible then consider copying the file to another file
and then use the copy of the file (which is not read only)
ASKER
It did not work with SystemFileObject but did work with the API. I should have tried that first.
If GetAttr("C:\Myfile.txt") And vbReadOnly Then
SetAttr "C:\Myfile.txt", vbNormal
End If