Belirtilen klasördeki tüm dosyaları tek tıklamayla silme
'// Forma bir adet buton ekleyin (Command1 adında)
Public 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
Public Const FO_DELETE = &H3
Public Const FOF_SILENT = &H4
Public Const FOF_RENAMEONCOLLISION = &H8
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_SIMPLEPROGRESS = &H100
Public Const FOF_ALLOWUNDO = &H40
Public Const FOF_FILESONLY = &H80&
Private Sub Command1_Click()
'// UYARI: AŞAĞIDAKİ İFADE, KLASÖRDKEİ TÜM DOSYALARI HERHANGİ BİR UYAR VERMEDEN SİLER !!!
Dim sFiles As String
Dim SHFileOp As SHFILEOPSTRUCT
sFiles = "D:\klasor\*.*" & Chr$(0) & Chr$(0)
With SHFileOp
.wFunc = FO_DELETE
.pFrom = sFiles
.fFlags = FOF_FILESONLY Or FOF_SILENT Or FOF_NOCONFIRMATION Or FOF_ALLOWUNDO
End With
Call SHFileOperation(SHFileOp)
End Sub