Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

List all files in folder with certain extension

I need VB .NET 2003 code for a windows form such that I can browse to folder location and then store in memory a list of all files with a certain extension.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 3
  • 2
1 Solution
 
Wayne Taylor (webtubbs)Commented:
Hi knowlton,

This line will store all files in a folder with a "xls" extension in a String array....

    Dim Files() as String = Directory.GetFiles("C:\FolderPath\", "*.xls")

Regards,

Wayne
0
 
Tom KnowltonWeb developerAuthor Commented:
What namespace is Directory found in?
0
 
Tom KnowltonWeb developerAuthor Commented:
Also

Once I call this:

Dim Files() as String = System.IO.Directory.GetFile(strPath, "*.mdb")


How do I loop through each file in Files( )?


Thanks...new to VB .NET
0
 
Wayne Taylor (webtubbs)Commented:
And to browse for the folder first....

        Dim FoldBrowser As New FolderBrowserDialog
        Dim Files() As String
        If FoldBrowser.ShowDialog = DialogResult.OK Then
            Files = System.IO.Directory.GetFiles(FoldBrowser.SelectedPath, "*.xls")
        End If

Wayne
0
 
Wayne Taylor (webtubbs)Commented:
Oops, sorry. Didn't realised you had posted.

To loop through each of the files once you've got the array, do something like this....

    For Each sFile As String In Files
         'sFile will return the FullPath to the file
    Next

Wayne
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now