Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Deleting in VB Runtime

Posted on 2000-03-10
8
Medium Priority
?
155 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 20

Expert Comment

by:hes
ID: 2605925
For a directory use rmdir

ie
rmdir "c:\test"
0
 
LVL 1

Accepted Solution

by:
karlww earned 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 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