Deleting ready-only AND memory loaded files

This is a discussion on Deleting ready-only AND memory loaded files within the C++ Programming forums, part of the General Programming Boards category; the API DeleteFile( ) delete files From MSDN, for platform Windows Me/98/95, it deletes the file regardless whether the file ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    114

    Deleting ready-only AND memory loaded files

    the API DeleteFile( ) delete files
    From MSDN, for platform Windows Me/98/95, it deletes the file regardless whether the file is loaded into memory or not. For other platforms, it doesnt delete if the file is loaded into memory.
    The file has to be closed before being deleted.

    Hence, if i am using win XP, how do i delete the file at all cost,whether it's loaded into memory or not?

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Quote Originally Posted by hanhao
    the API DeleteFile( ) delete files
    From MSDN, for platform Windows Me/98/95, it deletes the file regardless whether the file is loaded into memory or not. For other platforms, it doesnt delete if the file is loaded into memory.
    The file has to be closed before being deleted.

    Hence, if i am using win XP, how do i delete the file at all cost,whether it's loaded into memory or not?
    For other platforms, it doesnt delete if the file is loaded into memory. The file has to be closed before being deleted.
    You can't.

    If the file is open it can't be deleted because it's in use.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    114
    thnx for your reply

    i know i can close the file using closehandle API
    but i need the handle to the file
    any idea how to get this handle?

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    If you have admin priviliges you can use MoveFileEx() to delete the file on next reboot.

    If you are really nasty, want users to curse you and never run your program again, you can forcefully delete the file. Again, administrator priviliges are required.

    I don't see why MS doesn't provide a DeleteOnClose() function.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21