-
Sep 30th, 2024, 01:36 PM
#1
Thread Starter
Addicted Member
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 ?
-
Sep 30th, 2024, 01:47 PM
#2
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.
-
Sep 30th, 2024, 02:05 PM
#3
Thread Starter
Addicted Member
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 !
-
Sep 30th, 2024, 06:19 PM
#4
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 .
-
Sep 30th, 2024, 08:02 PM
#5
Re: Delete Files !
Originally Posted by LorinM
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.
-
Oct 1st, 2024, 12:17 AM
#6
Thread Starter
Addicted Member
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.
-
Oct 1st, 2024, 12:36 AM
#7
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
-
Oct 1st, 2024, 03:09 AM
#8
Re: Delete Files !
The op mentioned some program he apparently is working on, how about showing the relevant code?
-
Oct 1st, 2024, 03:31 AM
#9
Re: Delete Files !
Originally Posted by LorinM
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
-
Oct 1st, 2024, 05:25 PM
#10
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
-
Oct 1st, 2024, 08:14 PM
#11
Lively Member
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?
-
Oct 5th, 2024, 11:29 PM
#12
Thread Starter
Addicted Member
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
-
Oct 6th, 2024, 12:23 AM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|