Howdy.
I'm new to VB.net, but not to programming....
Is there a simple way to search a hard drive for a specific file type?
Seems like it would be a common thing, yet I'm not having much luck finding anything...
Thanks in advance!
Howdy.
I'm new to VB.net, but not to programming....
Is there a simple way to search a hard drive for a specific file type?
Seems like it would be a common thing, yet I'm not having much luck finding anything...
Thanks in advance!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Scott LysleRank #49 · 31K reputationPosted Sep 2, 2007, 7:01 PM EDT
Don:
Import System.IO and use the Directory.GetFiles methods. You can pass the method a search path and search pattern as arguments and it will return a string array containing the matching files. In the context of a console mode application, refer to the following for an example, in it, a string array called "files" is created and populated using the Directory.GetFiles call which is passed a search path (C:\Windows) and a search pattern (all executables (*.exe)).
Sub Main() Dim files() As String files = Directory.GetFiles("C:\Windows", "*.exe") Console.WriteLine() Console.WriteLine("Found " & files.Length & " EXE files") Dim file As String For Each file In files Console.WriteLine(file) Next 'wait Console.ReadLine() End SubDon Woodman3 reputationPosted Sep 15, 2007, 7:22 PM EDT
Thanks, Scott. You've got me going. I am having problems when searching at the
root directory. When I do, I get errors when my program comes to either the recycler or
system voloume information.
How to get around?
Don