I want to search the media files situated in my system by c#. means I want to create the search engine that will scan all drives (again small question here , how to get the drives on our system by c# code ? )and search the media files like .mp3,.mp4,...etc . How can i do that by c# desktop application?
try this:
List<string> mediaExtensions = new List<string>{"mp3", "mp4"};
List<string> filesFound = new List<string>();
void DirSearch(string sDir)
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, "*.*"))
{
if(mediaExtensions.Contains(Path.GetExtension(f).ToLower()))
filesFound.Add(f);
}
DirSearch(d);
}
}