I have an app that reads a huge text file (about more than 100MB) line by line.
As it takes so much time for the app to read the file, I'd like to add a StatusStripProgressBar at its bottom, indicating how much time remains until the end of loading.
I tried to compare the file length to the length of the strings being read, but I don't get the same result. I also tried to convert the string to bytes, but it still differs, for example:
while (!sr.EndOfStream)
{
s = sr.ReadLine;
TotalStringSize += s.Length;
UTF8ToASCII += UTF8Encoding.ASCII.GetByteCount(s);
UTF8ToBigEndianUnicode += UTF8Encoding.BigEndianUnicode.GetByteCount(s);
UTF8ToDefault += UTF8Encoding.Default.GetByteCount(s);
UTF8ToUnicode += UTF8Encoding.Unicode.GetByteCount(s);
UTF8ToUTF32 += UTF8Encoding.UTF32.GetByteCount(s);
UTF8ToUTF7 += UTF8Encoding.UTF7.GetByteCount(s);
UTF7ToASCII = UTF7Encoding.ASCII.GetByteCount(s);
//
// ...
//
}
The results I get are either higher or lower than the result given by System.IO.FileStream.Length
.
Any idea?
EDIT: The framework used is .NET 2.0