3
How to make the code not delete a specific file I want between the .exe
which I picked up. Example: I want it not to delete "test.exe", but still to continue erasing all the rest.
Follows the code:
string[] arquivos = Directory.GetFiles(@"C:\temp\ae", "*.exe", SearchOption.TopDirectoryOnly);
foreach (string arquivo in arquivos)
{
//nome = Path.GetFileName(arquivo);
File.Delete(arquivo);
}
i) Sometimes I wish I had the option of +5 for your answers; ii) Sometimes we were worried about making a code more readable (I say this in the sense of step by step) that we ended up going round and round and "spending" more than I should.
– Barbetta
I just didn’t give you +1 pq the first one is considerably less efficient than the second one, and it can mislead someone
– Maniero