Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,923 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
Is it too big to process file here,
https://1drv.ms/u/s!Ai8CrEskdewXvk21iZzHnqscSRwt?e=34UcMw
using codes below?
using (StreamReader sr = new StreamReader(@"e:/inp2.txt", System.Text.Encoding.ASCII)) { while ((line = sr.ReadLine()) != null) { //if (line.Trim() == "") //{ //} //else { //str.Add(line.Trim().Substring(6)); str.Add(line); //str.Add((line+"").Substring(5)); } } }
If the file is large, you cannot load it to memory, but often you can process it line-by-line.
For example, the next code counts the number of lines:
long count = 0;
foreach( string line in File.ReadLines( @"...path...", Encoding.ASCII ) )
{
// TODO: process 'line' variable
// . . .
++count;
}
Console.WriteLine( "Total lines: {0:#,##0}", count );
It only keeps the last line. Depending on your problem, you can also load and process a series of lines.