Results 1 to 13 of 13

Thread: Delete Files !

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    240

    Delete Files !

    Kill won't delete nor any API I have tried delete.

    So what does the program Unlocker do that I can do in VB6 to delete files ?

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,366

    Re: Delete Files !

    What files? Are these files that your own program has created and is using? If so, your program might still have the files opened which prevents them from being deleted. In that case, ensure that your program closes the files before attempting to delete them.

    Perhaps Windows is trying to protect you from yourself by not allowing you to delete some critical OS files.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    240

    Re: Delete Files !

    So you question makes no sense. Files, any file ! Even if I want to kill window, but I don't obviously.
    NO ! If I compile an addin I get .tmp files stuck even after closing the IDE. I have to use Unlocker to delete so another app can backup my files since the app dies if it cannot copy the locked file.

    Perhaps Windows is trying to annoy me, as usual !

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,336

    Re: Delete Files !

    The DeleteFile API won't delete files marked read only so in my calls to it I first use GetFileAttributes/SetFileAttributes to remove that and system if present.

    And OptionBase1's question makes perfect sense... If you or another program opened a file with a lock, you can't delete til it's closed. You can write your own "unlocked" routine to find and close handles held by other programs or another option is flag it to be deleted by Windows on reboot, before anything else can open it, with the MoveFileEx API flag MOVEFILE_DELAY_UNTIL_REBOOT and setting the new name to vbNullString for a string argument or 0 for Long .

  5. #5
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,366

    Re: Delete Files !

    Quote Originally Posted by LorinM View Post
    So you question makes no sense. Files, any file ! Even if I want to kill window, but I don't obviously.
    NO ! If I compile an addin I get .tmp files stuck even after closing the IDE. I have to use Unlocker to delete so another app can backup my files since the app dies if it cannot copy the locked file.

    Perhaps Windows is trying to annoy me, as usual !
    Ok champ.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    240

    Re: Delete Files !

    I remove the RO before trying to delete !
    Set attributes to normal if the will set.
    Then attempt to Kill or API delete and it will not.

  7. #7
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,535

    Re: Delete Files !

    There are a number of different reasons that may prevent a file from being deleted (killed).
    - the file is in the open state with your program.
    - the file is opened with another program.
    - the file is in a protected directory that requires admin rights.
    - the file is system or read-only.
    To identify the problem, go to the command line (cmd.exe):
    cd filedir
    attrib filename
    That will list the current attributes of the file in question. Archived files (A) in the closed state in a non-protected directory can be deleted using:
    del filename

    Otherwise you have to correct the correct the problem before attempting to delete or kill it. A read-only file for example can be corrected using -R with the attrib command.

    A unique problem can be created if you are using the API to open a file and the program ends suddenly because it encountered an error and ceased operation. If you are lucky enough to have a handle to the file, you can close it using an API call. Otherwise you may have to close the IDE or in rare cases even reboot to release the file.

    J.A. Coutts

  8. #8
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,891

    Re: Delete Files !

    The op mentioned some program he apparently is working on, how about showing the relevant code?

  9. #9
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,794

    Re: Delete Files !

    Quote Originally Posted by LorinM View Post
    So you question makes no sense. Files, any file ! Even if I want to kill window, but I don't obviously.
    NO ! If I compile an addin I get .tmp files stuck even after closing the IDE. I have to use Unlocker to delete so another app can backup my files since the app dies if it cannot copy the locked file.

    Perhaps Windows is trying to annoy me, as usual !
    Maybe those files are in a "protected" Folder (Program Files (x86))?
    Is he running whatever program (he mentioned IDE) elevated?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  10. #10
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    745

    Re: Delete Files !

    Sounds like the file is locked by the system or been used by a different process. you chould try running your program as admin if the file is in like a system folder if that does not work you may need to look at some low level way that maybe out of vbs scope duno if this helps but a quick found this.

    https://www.vbforums.com/showthread....k-locked-files

  11. #11
    Lively Member
    Join Date
    Aug 2024
    Posts
    122

    Re: Delete Files !

    Sounds like the file is locked by the system or been used by a different process

    the only thing this reminds me of, is when i am trying to run a program with the database open... i dunno if this helps.. does the OP have something open while running the program?

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    240

    Re: Delete Files !

    Cannot see the relevance.
    If the Unlocker program can do it then it should be possible with VB6.
    https://www.majorgeeks.com/files/details/unlocker.html

  13. #13
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,336

    Re: Delete Files !

    Yes it's possible but quite complicated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width