filesystemobject question
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: filesystemobject question

  1. #1
    Join Date
    Dec 2008
    Posts
    24

    filesystemobject question

    im using the filesystemobject to search for files in a folder and susbfolders then show these files in a listbox but when my form loads and executes the search the listbox fills with every file in the app.path how can i limit this to show .exe files and not everything else

    heres my code im using

    Code:
     form load event
    ListFolder App.Path
    then in

    Code:
    Private Sub ListFolder(sFolderPath As String)
        Dim FS As New FileSystemObject
        Dim FSfile
        Dim FSfolder As Folder
        Dim subfolder As Folder
       
        Set FSfolder = FS.GetFolder(sFolderPath)
        
        
        For Each FSfile In FSfolder.Files
            SelectionList.AddItem FSfile     'im sure i have to change this but its not having any of it
          
        Next FSfile
    
        For Each subfolder In FSfolder.SubFolders
                Call ListFolder(subfolder.Path)
        Next subfolder
        Set FSfolder = Nothing
    End Sub
    ive tried to change the code to find .exe only but to no avail

    thanks for any help

  2. #2
    Join Date
    Apr 2009
    Posts
    394

    Re: filesystemobject question

    Code:
    If UCase(Right(FSfile, 3)) = "EXE" Then SelectionList.AddItem FSfile


    Good Luck

  3. #3
    Join Date
    Dec 2008
    Posts
    24

    Re: filesystemobject question

    excellent thankyou very much

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center