| View previous topic :: View next topic |
| Author |
Message |
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 8th, 2003 04:06 AM Post subject: Delete a Folder And All It's Contents |
|
|
| 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 sPath As String, _
Optional blnToRecycleBin As Boolean = True, _
Optional blnConfirm As Boolean = True)
Dim fo As SHFILEOPSTRUCT
Dim nFlag As Long
If blnToRecycleBin Then
nFlag = FOF_ALLOWUNDO
End If
If blnConfirm = False Then
nFlag = nFlag + FOF_NOCONFIRMATION
End If
With fo
.pFrom = sPath & vbNullChar
.wFunc = FO_DELETE
.fFlags = nFlag
End With
SHFileOperation fo
End Sub |
|
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 10th, 2003 08:26 AM Post subject: |
|
|
| Code: | Private Sub DeleteFolder(sFolder As String)
If Right$(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
Kill sFolder & "*.*"
RmDir sFolder
End Sub |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
|