Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting .tmp files from the application directory 1

Status
Not open for further replies.

mclosson

Programmer
Mar 19, 2001
24
0
0
CA
I am trying to write code that will delete all .tmp files in the application path when the program closes. I do not want to use file system objects to do this for security reasons on the user side. If anyone has any ideas, please help me out.

I've tried to use the shell() function, but can't seem to get it to work.

Thanks,
Mike
 
What about the Kill() method?
 
Mclosson>
Try using the Shell command with the full path of .tmp's just responding to a command.

i.e. If a windows 9x User command being
[tt]
Private Sub command1_click()
SHELL &quot;DEL <application path>\*.tmp&quot;
End Sub
[/tt]

Application Path e.g. : C:\Progra~1\Micros~2\MyApp
If any help, get back to me as I had the same problem but it didn't work on one of my other machines..

Cheers, >:):O> ¥oshi >:):O>

 
I found that the SHELL() function was not doing anything. I think that the SHELL() in VB6 is meant only as a means of running programs almost as threads. For some reason, using regular dos prompts such as DEL do not seem to work. I was thinking of creating a .bat file that does the delete and then calling it from the SHELL() function, but I just ended up using the KILL() function and it worked fine for what I needed.

Thanks for the reply,
Mike
 
mc>

its not safe to use the shell as it creates a diffrent thread and you can't be assure whether it has done your work or not. try using the kill()

use a file control and make it disable or invisible for security reason

set its pattern property to *.tmp path property to app.path
and use
for x=1 to file1.listcount
kill app.path & &quot;\&quot; & file1.list(x)
next x

thats all . please excuse for my briefing
srusti
 
The problem with the Shell function is that you need to shell an executable (you can pass arguments).
Therefore your Shell line should read:
shell(&quot;cmd.exe del <application path>\*.tmp&quot;, vbHide)
The last parameter in the shell call is the window type (minimised, maximised etc)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top