ストリーミングしているファイルのサイズが非常に大きくなる可能性があるため、1mb から 2gb までのさまざまなサイズのファイルを読み取る必要があります。
- ファイルのどのくらいが読み取られたかを知り、すべての行を事前に読み取らずにそれを追跡するにはどうすればよいですか?
サンプルコード
int count = 0;
using (Stream stream = File.OpenRead(filename))
{
using (StreamReader reader = new StreamReader(stream))
{
string item = string.Empty;
while ((item = reader.ReadLine()) != null)
{
item = item.Replace("\"", ""); // remove unwanted double quotes
if (item.Length < 2) // dont need lines with less then 2 char
continue;
if (fine add to db)
count++; // to keep track of good lines
}
}
}