Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Deleting Files

Posted on 2003-02-28
6
Medium Priority
?
178 Views
Last Modified: 2010-05-01
In VB 6, what code can I use to delete files from a directory?
0
Comment
Question by:Patsfan
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8043181
you can use the VB Kill statement
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8043186
Kill "C:\my documents\*.*"
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8043189
sorry for the dup post emoreau
0
Independent Software Vendors: 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!

 

Author Comment

by:Patsfan
ID: 8043331
Thanks!  It worked fine.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 8043573
To close the question, you need to accept one of the comment. You will find a button for this on the gray bar separating comments.
0
 

Expert Comment

by:BlueSky007
ID: 8054370
Try this code (API):

Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long


DeleteFile "C:\KPD-Team\test.kpd"


If you what to delete more files use FINDFIRSTFILE function, after that use FindNextFunction. This is more usefull if you have System File, Hiden or ReadOnly Files

Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long

Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

581 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