Deleting in VB Runtime

    Hi, is it possible to delete a file or files and directories from within runtime?  Is so, is there a way to do the equivilent of a *.* ?
ShackmanAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
karlwwConnect With a Mentor Commented:
Why not just issue a couple of commands to the shell?
i.e.
Dim tid1 as Long
Dim tid2 As Long

tid1 = Shell("del c:\myprog\*.*", _
             vbHide)
tid2 = Shell("rd /s c:\myprog\dir_to_go", _
             vbHide)
0
 
RuchiCommented:
try this one?

Kill "c:\test\" & "*.*"
0
 
tkuppinenCommented:
To delete a file use my favorite command.

Kill "fullpathname"
eg.

kill "C:\myprogram\test.txt"

to kill all files in current directory

kill "*.*"

I am not sure about deleting directories.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
tkuppinenCommented:
Sorry ruchi.  I was typing before you posted.
0
 
hesCommented:
For a directory use rmdir

ie
rmdir "c:\test"
0
 
RuchiCommented:
Tkuppinen: No problem ;-)

DELETE FILE:
'Assume TESTFILE is a file containing some data.


 
Kill "TestFile"' Delete file.


 
Kill "*.TXT"' Delete all *.TXT files in current directory.


 
DELETE DIR:
' Assume that MYDIR is an empty directory or folder.
mDir "MYDIR"' Remove MYDIR.
0
 
RuchiCommented:
Oops..

DELETE DIR:
' Assume that MYDIR is an empty directory or folder.
RmDir "MYDIR"' Remove MYDIR.
0
 
wesleystewartCommented:
Be careful with Kill *.*

You might not be in the directory you think, and then BOOM, everything is screwed.

W
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.