|
-
Oct 10th, 2000, 02:29 PM
#1
Thread Starter
Member
is there a way in visual basic to delete a folder that contains files our other folders, like a deltree in dos.
I've tried "rmdir (path)" but there is a error if the folder contains file.
thanxs
-
Oct 10th, 2000, 02:34 PM
#2
Just use Deltree.
Code:
Shell "DELTREE /Y (path)", vbHide
Becareful, this could delete important files. It is very dangerous!
-
Oct 10th, 2000, 02:47 PM
#3
Fanatic Member
Code:
'You Need Microsoft Scripting Control for this.
'Not verified
Dim fOps As Object
Private Function DelTree(dirPath As String, Optional delReadOnly As Boolean) As Boolean
Set fOps = CreateObject("Scripting.FileSystemObject")
If fOps.FolderExists(dirPath) = True Then
If delReadOnly <> True Then
fOps.DeleteFolder dirPath
Else
fOps.DeleteFolder dirPath, delReadOnly
End If
DelTree = True
Else
DelTree = False
End If
End Function
This uses the Microsoft Scripting Control to create the object, but it's a pretty decent solution (I like the FileSystemObject :)
The Function is called thusly: DidDelete = delTree(PATH,[True/False])
If True is set, it will delete read only folders, if false is set, it will not. Path is the directory you wish to delete. The function returns either a true or a false indicating it's level of success.
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
|