Удалить определенные файлы в каталоге с помощью C #

В моем каталоге C: \ TEMP есть много файлов .bmp.

Я использую следующий код для удаления всех файлов .bmp в моем каталоге C: \ TEMP, но каким-то образом его не работает, как я ожидал. Кто-нибудь может мне в этом помочь?

string[] filePaths = Directory.GetFiles(@"c:\TEMP\");
foreach (string filePath in filePaths)
{
    if (filePath.Contains(".bmp"))
        File.Delete(filePath);
}

Я это уже проверил. System.nanoTime(); Both methods are implemented native. Before digging into any C ...

When measuring elapsed time on a low level, I have the choice of using any of these:

System.currentTimeMillis();
System.nanoTime();

Both methods are implemented native. Before digging into any C code, does anyone know if there is any substantial overhead calling one or the other? I mean, if I don't really care about the extra precision, which one would be expected to be less CPU time consuming?

N.B: I'm using the standard Java 1.6 JDK, but the question may be valid for any JRE...

45
задан Lukas Eder 12 April 2011 в 19:40
поделиться