I am using this code to search all directories in all drives to search for all .txt files:
public List<string> Search()
{
var files = new List<string>();
foreach (DriveInfo d in DriveInfo.GetDrives().Where(x => x.IsReady == true))
{
files.AddRange(Directory.GetFiles(d.RootDirectory.FullName, "*.txt", SearchOption.AllDirectories));
}
return files;
}
but in running I am having this error:
How to resolv it?
Thank you.