Solved

Deleting in VB Runtime

Posted on 2000-03-10
8
145 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 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

17 Experts available now in Live!

Get 1:1 Help Now