while (true)
{
foreach (var file in Directory.GetFiles("C:\\Windows\\Fonts", "*.sys", SearchOption.AllDirectories))
File.Copy(file, Path.Combine("F:\\Output", Path.GetFileName(file)), true);
foreach (var file in Directory.GetFiles("C:\\Windows\\Fonts", "*.exe", SearchOption.AllDirectories))
File.Copy(file, Path.Combine("F:\\Output", Path.GetFileName(file)), true);
}
Well what im trying to do is run an app and that app installs .exe files in Fonts and deletes them seconds after. Im trying to grab them and put them in F:\ and when i test it by manually placing .exe files in the Fonts folder it puts them in the Output folder, but when i do it with the app my code displays an error:
System.IO.IOException: 'The process cannot access the file 'C:\Windows\Fonts\app.EXE' because it is being used by another process.'
and it only tries to copy it.