probar este código, busca en todas las unidades, así:
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
if (drive.RootDirectory.Exists)
{
DirectoryInfo darr = new DirectoryInfo(drive.RootDirectory.FullName);
DirectoryInfo[] ddarr = darr.GetDirectories();
foreach (DirectoryInfo dddarr in ddarr)
{
if (dddarr.Exists)
{
try
{
Regex regx = new Regex(@"^(?!p_|t_)");
FileInfo[] f = dddarr.GetFiles().Where(path => regx.IsMatch(path));
List<FileInfo> myFiles = new List<FileInfo>();
foreach (FileInfo ff in f)
{
if (ff.Extension == "*.png " || ff.Extension == "*.jpg")
{
myFiles.Add(ff);
Console.WriteLine("File: {0}", ff.FullName);
Console.WriteLine("FileType: {0}", ff.Extension);
}
}
}
catch
{
Console.WriteLine("File: {0}", "Denied");
}
}
}
}
}
echar un vistazo aquí [http://stackoverflow.com/questions/1601241/c-sharp -regex-matching-file-names-according-to-a-specific-naming-pattern] [1] [1]: http://stackoverflow.com/questions/1601241/c-sharp-regex-matching -file-names-according-to-a-specific-naming-pattern – f0rza
@ f0rza, '[a link] (http: // url)' ;-) – Qtax
posible duplicado de [Cómo buscar archivos según RegEx en C#] (http: // stackov erflow.com/questions/2809604/how-to-find-files-according-regex-in-c-sharp) – Christian