Solved

Deleting in VB Runtime

Posted on 2000-03-10
8
143 Views
Last Modified: 2010-05-02
    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 *.* ?
0
Comment
Question by:Shackman
8 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2605901
try this one?

Kill "c:\test\" & "*.*"
0
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2605915
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
 
LVL 1

Expert Comment

by:tkuppinen
ID: 2605917
Sorry ruchi.  I was typing before you posted.
0
 
LVL 20

Expert Comment

by:hes
ID: 2605925
For a directory use rmdir

ie
rmdir "c:\test"
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Accepted Solution

by:
karlww earned 100 total points
ID: 2605932
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
 
LVL 9

Expert Comment

by:Ruchi
ID: 2605934
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
 
LVL 9

Expert Comment

by:Ruchi
ID: 2605939
Oops..

DELETE DIR:
' Assume that MYDIR is an empty directory or folder.
RmDir "MYDIR"' Remove MYDIR.
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2605941
Be careful with Kill *.*

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

W
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
z = x + y – 1 6 59
vba find the last empty column 10 81
bit defender blocks good applications 2 56
Microsoft Access combo box help 2 30
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now