how can i delete multiple files that i select from a filelist ?
can anyone help ???
Printable View
how can i delete multiple files that i select from a filelist ?
can anyone help ???
Something like:
Gl,Code:Kill (File1.Path & "\" & File1.FileName)
D!m
Loop through the File List and kill the file if it is selected:
Good luck!Code:Private Sub DeleteFiles()
Dim i%
With File1
ChDir File1.Path
For i = .ListCount - 1 To 0
If .Selected(i) Then
Kill .List(i)
End If
Next
End With
End Sub
Don't forget the Step -1
Quote:
Originally posted by Joacim Andersson
Loop through the File List and kill the file if it is selected:
Good luck!Code:Private Sub DeleteFiles()
Dim i%
With File1
ChDir File1.Path
For i = .ListCount - 1 To 0
If .Selected(i) Then
Kill .List(i)
End If
Next
End With
End Sub
Whithout using a control, and a little better and faster
VB Code:
Private Sub Form_Load() ' deletes all files in myfiles DeleteAllFiles "C:\MyFiles" ' deletes all files of type tmp DeleteAllFiles "C:\Temp", "*.tmp" End Sub Private Sub DeleteAllFiles(ByVal PathName As String, Optional FileType As String = "*.*") If Right(PathName, 1) <> "\" Then pathame = PathName & "\" Do Until Dir(PathName & FileType, vbArchive + vbHidden) = "" Kill PathName & Dir(PathName & FileType, vbArchive + vbHidden) Loop End Sub