|
-
Jun 16th, 2003, 02:39 PM
#1
Thread Starter
Need-a-life Member
DeleteTree
Is there an API or way to perform a DeleteTree easily?
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jun 16th, 2003, 02:42 PM
#2
Let me in ..
Re: DeleteTree
Originally posted by Mc Brain
Is there an API or way to perform a DeleteTree easily?
Well - what is a deletetree ??
-
Jun 16th, 2003, 02:45 PM
#3
Thread Starter
Need-a-life Member
It's an old command (DelTree) of DOS that deletes all the files and folder on a specific folder (and on its children).
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jun 16th, 2003, 02:53 PM
#4
PowerPoster
Originally posted by Mc Brain
It's an old command (DelTree) of DOS that deletes all the files and folder on a specific folder (and on its children).
I think the FilesystemObject has a deleteFolder method that does that, doesnt it?
-
Jun 16th, 2003, 02:53 PM
#5
Let me in ..
Originally posted by Mc Brain
It's an old command (DelTree) of DOS that deletes all the files and folder on a specific folder (and on its children).
You could use FileSystemObject's DeleteFolder property ...
-
Jun 16th, 2003, 02:54 PM
#6
Thread Starter
Need-a-life Member
Thanks... I was looking for an API really. I'm not fond of the FSO.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jun 16th, 2003, 02:55 PM
#7
Let me in ..
Originally posted by Mc Brain
Thanks... I was looking for an API really. I'm not fond of the FSO.
Me neither .. let me see if i can find you some API ...
-
Jun 16th, 2003, 02:56 PM
#8
Let me in ..
You can write a recursive loop to delete all files using DeleteFile API and then use RemoveDirectory to remove folders. Its easy.
-
Jun 16th, 2003, 03:05 PM
#9
PowerPoster
-
Jun 16th, 2003, 03:46 PM
#10
Give this a try.
VB Code:
Private Declare Function SHFileOperation _
Lib "shell32.dll" Alias "SHFileOperationA" ( _
lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Public Sub DeleteFolder(ByVal strPath As String, _
Optional blnToRecycleBin As Boolean = True, _
Optional blnConfirm As Boolean = True)
''''''''''''''''''''''''''''''''''''''''''''''''
'Parameters
'strPath - The folder path
'blnToRecycleBin - True sends the file to the
' Recycle Bin. False deletes the file without
' sending it to the Recyle Bin.
'blnConfirm - True pops up a dialog to confirm
' delete. False deletes silently.
'
' EXAMPLES:
'' Send folder to Recycle bin with confirmation
' DeleteFolder "c:\test folder"
'
'' Send folder to Recycle bin without confirmation
' DeleteFolder "c:\test folder", , False
'
'' Deletes folder by passing Recycle Bin with confirmation
'' DeleteFolder "c:\test folder", False
'
'' Deletes folder by passing Recycle Bin with confirmation
'' DeleteFolder "c:\test folder", False, False
'''''''''''''''''''''''''''''''''''''''''''''''
Dim FileOp As SHFILEOPSTRUCT
Dim lngFlag As Long
If blnToRecycleBin Then
lngFlag = FOF_ALLOWUNDO
End If
If blnConfirm = False Then
lngFlag = lngFlag + FOF_NOCONFIRMATION
End If
With FileOp
.pFrom = strPath & vbNullChar
.wFunc = FO_DELETE
.fFlags = lngFlag
End With
SHFileOperation FileOp
End Sub
-
Jun 16th, 2003, 04:33 PM
#11
Thread Starter
Need-a-life Member
Originally posted by MarkT
Give this a try.
VB Code:
Private Declare Function SHFileOperation _
Lib "shell32.dll" Alias "SHFileOperationA" ( _
lpFileOp As SHFILEOPSTRUCT) As Long
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Public Sub DeleteFolder(ByVal strPath As String, _
Optional blnToRecycleBin As Boolean = True, _
Optional blnConfirm As Boolean = True)
''''''''''''''''''''''''''''''''''''''''''''''''
'Parameters
'strPath - The folder path
'blnToRecycleBin - True sends the file to the
' Recycle Bin. False deletes the file without
' sending it to the Recyle Bin.
'blnConfirm - True pops up a dialog to confirm
' delete. False deletes silently.
'
' EXAMPLES:
'' Send folder to Recycle bin with confirmation
' DeleteFolder "c:\test folder"
'
'' Send folder to Recycle bin without confirmation
' DeleteFolder "c:\test folder", , False
'
'' Deletes folder by passing Recycle Bin with confirmation
'' DeleteFolder "c:\test folder", False
'
'' Deletes folder by passing Recycle Bin with confirmation
'' DeleteFolder "c:\test folder", False, False
'''''''''''''''''''''''''''''''''''''''''''''''
Dim FileOp As SHFILEOPSTRUCT
Dim lngFlag As Long
If blnToRecycleBin Then
lngFlag = FOF_ALLOWUNDO
End If
If blnConfirm = False Then
lngFlag = lngFlag + FOF_NOCONFIRMATION
End If
With FileOp
.pFrom = strPath & vbNullChar
.wFunc = FO_DELETE
.fFlags = lngFlag
End With
SHFileOperation FileOp
End Sub
Great, MarkT! It worked! Thanks a lot.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jun 6th, 2006, 02:24 PM
#12
Hyperactive Member
-
Jun 6th, 2006, 05:20 PM
#13
Re: DeleteTree
VB Code:
'' Send folder to Recycle bin without confirmation
' DeleteFolder "c:\test folder", , False
-
Jun 7th, 2006, 04:59 AM
#14
Hyperactive Member
Re: DeleteTree
 Originally Posted by cssriraman
VB Code:
'' Send folder to Recycle bin without confirmation
' DeleteFolder "c:\test folder", , False
I wasnt asking how to do it, i was just saying that this thread pointed out to me how to use the FOF_NOCONFIRMATION flag, that's all !!!
But thx anyways ....
"And Now I'm Lika Major Threat, Cause I Remind U Of The Things U Were Made To Forget!" - (2PAC)
"Now They Label Me a Lunatic, Couldn't Care Less, Death or Success is What I Quest, Cause I'm Fearless!" - (2PAC)
" There's a light at the end of every tunnel, just pray it's not a train!! "
I am 100% addicted to Tupac. What about you?
I am 24% addicted to Counterstrike. What about you?
The #1 Tupac Fans Web Site | The Official Tupac Web Site
-
Jun 7th, 2006, 07:59 AM
#15
-
Feb 16th, 2007, 12:38 PM
#16
Lively Member
Re: DeleteTree
Ok... this thread is now 3.5 years old and just saved my bacon!!!
Thanks!!!!!
I was having a problem with the FSO.DeleteFolder method... it refused to cooporate...
-
Feb 16th, 2007, 12:42 PM
#17
Re: DeleteTree
Doing a forum search does pay off.
-
Feb 16th, 2007, 12:47 PM
#18
Lively Member
Re: DeleteTree
man, preach'n to the choir, brah... preach'n to the choir.
I am active at www.corvetteforum.com... and that is always one of my first recommendations. However, 98% are not IT pros and they don't think of using the search - or don't have a clue how it works.
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
|