system.IO.File and System.IO.FileInfo slow
-
Certain IO methods, particularly FileInfo.LastWriteTime and FileInfo.Size are excruciatingly slow, especially the first time around. I know the first time around is slow because the files haven't been cached yet. But it's excruciatingly slow; for a folder of about 1000 files, the cmd.exe dir command can do it in a few seconds whereas it takes System.IO.File and System.IO.FileInfo more than 30 seconds. I noticed PowerShell has this problem too, since the ls/dir cmdlets use FileInfo as well. Any ideas on a workaround/remedy? Thanks in advance, Rei
-
Certain IO methods, particularly FileInfo.LastWriteTime and FileInfo.Size are excruciatingly slow, especially the first time around. I know the first time around is slow because the files haven't been cached yet. But it's excruciatingly slow; for a folder of about 1000 files, the cmd.exe dir command can do it in a few seconds whereas it takes System.IO.File and System.IO.FileInfo more than 30 seconds. I noticed PowerShell has this problem too, since the ls/dir cmdlets use FileInfo as well. Any ideas on a workaround/remedy? Thanks in advance, Rei
Write the code to do it in C++, perhaps using C++/CLI so you can call it from C#.
Christian Graus - C++ MVP