Avatar of Neal Hartman
Neal HartmanFlag for United States of America asked on

MoveFileEx

If OrigionalFile is open, this works fine:
MoveFileEx(NewFile, OrigionalFile, MOVEFILE_DELAY_UNTIL_REBOOT + 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!
Visual Basic Classic

Avatar of undefined
Last Comment
Neal Hartman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
crazyman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
vinnyd79

or maybe:

If GetAttr("C:\Myfile.txt") And vbReadOnly Then
    SetAttr "C:\Myfile.txt", vbNormal
End If
___XXX_X_XXX___

Because:
MOVEFILE_DELAY_UNTIL_REBOOT      
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.
unknown_routine

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)
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
Neal Hartman

It did not work with SystemFileObject but did work with the API. I should have tried that first.