Solved

List all files in folder with certain extension

Posted on 2006-11-01
5
236 Views
Last Modified: 2010-04-23
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
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 17853874
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
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 17853896
What namespace is Directory found in?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 17853919
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
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 17853934
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
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 17853952
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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question