reading large text file c# code example
Example: c# read large file
int filesize = (new FileInfo(filePath)).Length;
using (Stream sr = File.OpenRead(filePath))
{
int maxchunk = 1024;
for(long x = 0; x < totalChunk; x++ )
{
long LefttotalLegth = filesize - (x * maxchunk);
long leghtcopy = Math.Min(maxchunk, LefttotalLegth);
byte[] chunkbyte = new byte[leghtcopy];
sr.Read(chunkbyte, 0, chunkbyte.Length);
//Do something after read. like write to file
}
}