Solved

List all files in folder with certain extension

Posted on 2006-11-01
5
232 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:knowlton
  • 3
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
Comment Utility
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:knowlton
Comment Utility
What namespace is Directory found in?
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
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)
Comment Utility
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)
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now