Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have a vb.net application with an openfiledialog control on the form with a filter for .mdb's. The user selects the database and the filename property of the dialog box puts the path in a textbox on the form. What I also need the program to do is perform a recursive search for tif's starting in the directory where the database is located in and search all the directories that might be below the directory of the database. Any programming examples of how to accomplish this task is greatly appreciated.
Posted
I have a vb.net application with an openfiledialog control on the form with a filter for .mdb's. The user selects the database and the filename property of the dialog box puts the path in a textbox on the form. What I also need the program to do is perform a recursive search for tif's starting in the directory where the database is located in and search all the directories that might be below the directory of the database. Any programming examples of how to accomplish this task is greatly appreciated.

 

Imports System.IO

Public Class FindFiles

   Public Shared Function FindFiles(ByVal basePath As String, ByVal searchPattern As String) As ArrayList
       Dim result As New ArrayList

       For Each dir As String In Directory.GetDirectories(basePath)
           result.AddRange(FindFiles(dir, searchPattern))
       Next

       For Each file As String In Directory.GetFiles(basePath, searchPattern)
           result.Add(file)
       Next

       Return result

   End Function


End Class

 

Called like so:

 

Dim result As ArrayList = FindFiles.FindFiles("some directory", "*.tif")

-=splice=-

It's not my fault I'm a Genius!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...