By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

How to write a program to search the computer for files.

P: n/a
Greetings unto thee.

I want to know how to write an application in vb.net that will search my
computer for files.

An example: Windows Media Player has an option to search your pc for media
files and import them to its media library.

I want to know how to do that (the searching part, not the importing)

Your assistance in this regrard will be utmost appreciated.
--
TTB
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
It's simply a recursive procedure, starting at the root and recursing
through sub-directories - you can maintain a collection of "found" items as
you go....:

Public Sub Scan (ByVal theFoundItems as ArrayList, ByVal theRoot as String)

Scan_Aux ( theFoundItems, theRoot )

End Sub

Public Sub Scan_Aux ( ByVal theFoundItems As ArrayList, ByVal theRoot As
String)

' First recurse through to the leaves....

Dim theDirectories() As String = Directory.GetDirectories ( theRoot )

For Each theDirectory As String In theDirectories
Scan_Aux ( theFoundItems, theDirectory )
Next

' Now scan the files in the current directory for any that match...

Dim theFiles() As String = Directory.GetFiles ( theRoot )

For Each theFile As String In theFiles

If ....<the file matches our criteria> Then
theFoundItems.Add theFile
End If

Next

End Sub

"Treasure Baloyi" <Tr************@discussions.microsoft.com> wrote in
message news:48**********************************@microsof t.com...
Greetings unto thee.

I want to know how to write an application in vb.net that will search my
computer for files.

An example: Windows Media Player has an option to search your pc for media
files and import them to its media library.

I want to know how to do that (the searching part, not the importing)

Your assistance in this regrard will be utmost appreciated.
--
TTB

Nov 21 '05 #2

P: n/a
"Treasure Baloyi" <Tr************@discussions.microsoft.com> schrieb:
I want to know how to write an application in vb.net that will search my
computer for files.
[...]
I want to know how to do that (the searching part, not the importing)


<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/FileSystemEnumerator.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.