Results 1 to 5 of 5

Thread: deleting multiple files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Israel
    Posts
    79

    Question



    how can i delete multiple files that i select from a filelist ?

    can anyone help ???


  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Something like:
    Code:
    Kill (File1.Path & "\" & File1.FileName)
    Gl,
    D!m
    Dim

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Loop through the File List and kill the file if it is selected:
    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
    Good luck!

  4. #4
    Addicted Member
    Join Date
    Dec 2002
    Posts
    196
    Don't forget the Step -1




    Originally posted by Joacim Andersson
    Loop through the File List and kill the file if it is selected:
    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
    Good luck!
    Brandon S Davids

  5. #5
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    Whithout using a control, and a little better and faster

    VB Code:
    1. Private Sub Form_Load()
    2.     ' deletes all files in myfiles
    3.     DeleteAllFiles "C:\MyFiles"
    4.    
    5.     ' deletes all files of type tmp
    6.     DeleteAllFiles "C:\Temp", "*.tmp"
    7. End Sub
    8.  
    9. Private Sub DeleteAllFiles(ByVal PathName As String, Optional FileType As String = "*.*")
    10.     If Right(PathName, 1) <> "\" Then pathame = PathName & "\"
    11.    
    12.     Do Until Dir(PathName & FileType, vbArchive + vbHidden) = ""
    13.         Kill PathName & Dir(PathName & FileType, vbArchive + vbHidden)
    14.     Loop
    15. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width