2つの日付の間でファイルを読み込み、その値をデータテーブルに追加します。次に、ページングを使用してデータ可能な値をグリッドに表示する必要があります。しかし、問題は、これらのファイルには膨大な量のデータが含まれていることです(1M以上)。だから私はdatatable.soでページングしたいのですが、どうすればいいのですか?サンプルコードのアイデアをお願いします。C#を使用してデータテーブルをページングする方法
public DataTable CreateDataSource(DateTime fromDate, DateTime toDate)
{
int i = 0;
string visitorCountry = "";
try
{
dt = dtVisitLog();
for (DateTime x = fromDate; x <= toDate; x = x.AddDays(1))
{
string startDate = x.Year.ToString().Substring(2, 2) + x.Month.ToString("d2") + x.Day.ToString("d2");
string FILE_NAME = pathName + "\\u_ex" + startDate + ".log";
if (File.Exists(FILE_NAME))
{
FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);
StreamReader sr = new StreamReader(fs);
string strResult = sr.ReadToEnd();
sr.Dispose();
fs.Dispose();
sr = null;
fs = null;
string[] arLogLines = strResult.Split(Convert.ToChar("\n"));
for (i = arLogLines.Length-2; i > 3; i--)
{
string[] attribute = arLogLines[i].Split(Convert.ToChar(" "));
dt.Rows.Add(attribute[0], attribute[1], attribute[8], attribute[4], attribute[7], visitorCountry);
}
}
}
return dt;
}
catch (Exception ex)
{
return null;
}
}