Recursive File Search in .net

Saif Khan picture Saif Khan · Jan 13, 2009 · Viewed 13.3k times · Source

I need to search a drive (C:, D: etc) for a partuicular file type (extension like .xml, .csv, .xls). How do I preform a recursive search to loop all directories and inner directories and return the full path of where the file(s) are? or where can I get information on this?

VB.NET or C#

Thanks

Edit ~ I am running into some errors like unable to access system volume access denied etc. Does anyone know where I can see some smaple code on implementing a file search? I just need to search a selected drive and return the full path of the file type for all the files found.

Answer

Cristian Libardo picture Cristian Libardo · Jan 13, 2009
System.IO.Directory.GetFiles(@"c:\", "*.xml", SearchOption.AllDirectories);