|
-
Mar 31st, 2004, 07:01 AM
#1
Thread Starter
Member
file Deletion
Hi there ...
I have a small prob in my code ...
I have a folder name and a list of file extensions
now I want to delete all the files with those particular extensions
these files can also be in the subfolders of the pathfolder...
how should I do it?
Its urgent...
Regards,
Nahush
-
Mar 31st, 2004, 07:03 AM
#2
Fanatic Member
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
-
Mar 31st, 2004, 07:08 AM
#3
I imagine one of the easier ways would be to use FSO, though not the most desirable sometimes...
VB Code:
Private Sub Command1_Click()
Dim fso As New FileSystemObject
Call EnumDelete(fso.GetFolder("C:\"), "*.tmp")
Set fso = Nothing
End Sub
Private Sub EnumDelete(Path As Folder, DeletePattern As String)
Dim fld As Folder
On Error Resume Next
Kill Path.Path & DeletePattern
On Error GoTo 0
For Each fld In Path.SubFolders
Call EnumDelete(fld, DeletePattern)
Next
End Sub
Add a reference to the Microsoft Scripting Runtime.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 31st, 2004, 07:09 AM
#4
Thread Starter
Member
Urgent
hi there
does kill also deletes all the those particular files from the
sub directories also?
my prob is those file s can be in sub folders of the foler...
Nahush
-
Mar 31st, 2004, 08:22 AM
#5
Supreme User
You would have to loop through all sub folders killing the specified extension on its loop. Not sure how, but the idea would be to kill like:
Folder
---File1
---File2
---Sub Folder
------File3
------Sub Folder
---------File4
---------File5
etc, how about a look on Planet Source Code?
-
Mar 31st, 2004, 08:43 AM
#6
Guff to that, just look a couple of posts up.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|