Directory c:\\test has 50 or so files in it, no subdirectories.
If IO.Directory.Exists(\"C:\\test\") Then
IO.Directory.Delete(\"C:\\test\", True)
I suspect that you've found a race condition in NTFS that was previously not exposed since drives didn't exist that were fast enough to hit it. I don't think that TRIM has anything to do with it (though I reserve the right to be wrong!)
Either way, the proper way to handle this is to put the code in a Retry loop:
int retries = 3;
while(true) {
try {
doTheOperation();
break;
} catch (Exception ex) {
retries--;
if (retries == 0) {
throw;
}
Thread.Sleep(100);
continue;
}
}