0

膨大なファイルリストから前日のファイルを選択しています

// selecting around 80-120 files from 20,000 - 25,000 

FileInfo[] files = (new DirectoryInfo(dirPath)).GetFiles("*.xml");
 string[] selectedFiles = (from c in files
                                          where c.CreationTime >= DateTime.Today.AddDays(-1) && c.CreationTime < DateTime.Today.AddHours(-2.0)
                                          select c.FullName).ToArray();

上記の実行には約4〜5分かかります。機能を変更せずに最適化する方法を教えてください。

// file selection is between yesterday 0:00 to yesterday 22:00 <br >

上記のコードに示されているように。
親切にアドバイス。

4

2 に答える 2

1

試してみること:

FileInfo[] files = (new DirectoryInfo(dirPath)).GetFiles("*.xml");

DateTime lowDate = DateTime.Today.AddDays(-1);
DateTime highDate = DateTime.Today.AddHours(-2.0);

 string[] selectedFiles = (from c in files
                                          where c.CreationTime >= lowDate && c.CreationTime < highDate
                                          select c.FullName).ToArray();

これらの日付は、それぞれ 20,000 回以上計算されている可能性があります。

于 2013-02-22T17:06:29.113 に答える