We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 104,625 times

Related Categories

List Files in a Directory

JesusFreak

A little code snippet that lists files in a directory.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' make a reference to a directory
    Dim di As New IO.DirectoryInfo("c:\")
    Dim diar1 As IO.FileInfo() = di.GetFiles()
    Dim dra As IO.FileInfo

   'list the names of all files in the specified directory
    For Each dra In diar1
        ListBox1.Items.Add(dra)
    Next
End Sub

To filter search change di.GetFiles() to di.GetFiles(“.extionsion”)

Comments

  • Feedback

    Posted by DocStone on 16 Nov 2005

    [code]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    ListBox1.Items.Clear()

    Dim base_dir As New IO.DirectoryInfo(ba...

  • Posted by inertia on 09 Aug 2005

    if you want to run the code in a thread so it doesn't tie up the GUI during long searches you can do this

    [code]
    Dim makeNewThread As New System.Threading.Thread(AddressOf SubNameHere)
    ...

  • Posted by inertia on 09 Aug 2005

    [quote][1]Posted by [b]martini82[/b] on 4 Aug 2005 12:52 AM[/1]
    This file search seems really nice. Do you know what library to add in the project Reference in order to use File I/O?

    I'm getting ...

  • Posted by inertia on 09 Aug 2005

    [quote][1]Posted by [b]hammett[/b] on 9 Aug 2005 01:38 AM[/1]
    What parameter do I supply for Array when calling the sub?
    [/quote]

    define an arraylist and a string in your calling routine like thi...

  • Posted by hammett on 09 Aug 2005

    What parameter do I supply for Array when calling the sub?