tags:

views:

16

answers:

2

Hi, I How can I search a specific file using vb.net and store the path in a variable? For example if I need to know where I have *.abc files in my entire computer, how can this be done? Thanks Furqan

A: 

There's the EnumerateFiles method that has been introduced in .NET 4.0. If not you could use the GetFiles method but be warned that this method returns an array of strings which represent the matched filenames and it could block for a long time.

Darin Dimitrov
A: 
    Dim di As New DirectoryInfo("c:\")
    Dim files() As FileInfo = di.GetFiles("*.abc", SearchOption.AllDirectories)
Patricker
I tried the code but error saysDirectoryInfo not definedfile info not definedAlso, how can I store the path into a variable
Both of those types are in System.IO, so you'll need to put a Import statement for System.IO at the top of your code file, maybe add a reference to it if you don't have one already.
Patricker