string Textfile = @"C:\hello.txt";
Encoding enc = Encoding.Default;
FileInfo fi = new FileInfo(textfile);long remainingTillEnd = fi.Length;
int readTotalUntilNow = 0;int blocksize = 4096;
char[] buffer = new char[blocksize];
using (StreamReader sr = new StreamReader(Textfile,enc))
{
bool readon = true;
while (readon)
{
if (remainingTillEnd > blocksize)
{
readTotalUntilNow += sr.ReadBlock(buffer, 0, blocksize);
}
else
{
readTotalUntilNow += sr.ReadBlock(buffer, 0, (int)remainingTillEnd);
readon = false; // last block indicator
}
remainingTillEnd = fi.Length - readTotalUntilNow;
}
}
Benefit from the best Windows Desktop app in the world and use Strokey.Net!