i wrote a code to search a file in the external devices like external hard disk
read the code line by line so u can understand properly
private static void SearchForFiles(string path, string pattern, List<string> SearchResults)
{
foreach (string file in Directory.GetFiles(path, pattern))
{
SearchResults.Add(file);
}
foreach (string dir in Directory.GetDirectories(path))
{
try
{
SearchForFiles(dir, pattern, SearchResults);
}
catch (Exception ex)
{
}
}
}
private void button1_Click(object sender, EventArgs e)
{
string myString;
List<string> SearchResults = new List<string>();
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if(d.Name.ToString() != "C:\\" && d.Name.ToString() != "D:\\")
if (d.IsReady == true)
{
myString = String.Format(" {0}", d.Name);
SearchForFiles(myString, "vlc.exe", SearchResults);
}
}
foreach (string s in SearchResults)
{
Process.Start(s); <<<<<<<===== problem is here i'll get error when i compile as "the system cannot find the file specified"
}
}
so please any body guide me or correct my code please
thank you