Solved

Deleting in VB Runtime

Posted on 2000-03-10
8
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protecting vb6 & .Net code Obfuscation 18 217
Child Form in front 4 66
Create Files based on Cell Values in a Range in Excel 12 44
IF ELSE Statement in Excel Macro VBA 16 104
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

752 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