Finding a File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the best way to find a file? I don't know the directory but the file
is almost certainly on the c drive.

Thanks
 
What is the best way to find a file? I don't know the directory but the file
is almost certainly on the c drive.

Thanks

You can do a search by using the DirectoryInfo.GetFiles and
DirectoryInfo.GetDirectories. Take a look at the class I posted here:

http://groups.google.com/group/micr...l=en&lnk=gst&q=zacks&rnum=13#c6135c3c82347084

Once you enumerate the root folder, you can then use a for/each loop
on the Files property to find the file. Just load a FileInfo object
with each file and then look at the Name property there to look for
the file you are looking for.
 
You can do a search by using the DirectoryInfo.GetFiles and
DirectoryInfo.GetDirectories. Take a look at the class I posted here:

http://groups.google.com/group/micr...l=en&lnk=gst&q=zacks&rnum=13#c6135c3c82347084

Once you enumerate the root folder, you can then use a for/each loop
on the Files property to find the file. Just load a FileInfo object
with each file and then look at the Name property there to look for
the file you are looking for.

If you are using VB 2005 then in the namespace
Microsoft.VisualBasic.FileIO.FileSystem there is a GetFiles function which
can search for files with wildcards and will do the recursive thing by using
a parameter in the function call.

Hope this helps
Lloyd Sheen
 
Back
Top