Solved

List all files in folder with certain extension

Posted on 2006-11-01
5
237 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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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