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 *.* ?
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.
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.
For a directory use rmdir
ie
rmdir "c:\test"
ie
rmdir "c:\test"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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
You might not be in the directory you think, and then BOOM, everything is screwed.
W
Kill "c:\test\" & "*.*"