Link to home
Start Free TrialLog in
Avatar of Shackman
Shackman

asked on

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 *.* ?
Avatar of Ruchi
Ruchi

try this one?

Kill "c:\test\" & "*.*"
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.
Sorry ruchi.  I was typing before you posted.
Avatar of hes
For a directory use rmdir

ie
rmdir "c:\test"
ASKER CERTIFIED SOLUTION
Avatar of karlww
karlww

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Oops..

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

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

W