I try to use this code for deleting files that contain a specific string in all subfolders of c:\
void Delete()
{
string rootFolderPath = @"C:\";
string filesToDelete = @"*apple*.algo"; // Only delete files containing "apple" in their filenames
string[] fileList = System.IO.SearchOption.AllDirectories(rootFolderPath, filesToDelete);
foreach(string file in fileList)
{
System.Diagnostics.Debug.WriteLine(file + "will be deleted");
System.IO.File.Delete(file);
}
}