G
Guest
Hello,
I am reading a number of files in a directory and doing some work after
reading each line of the file. What I want to have is a progress bar that
gets updated as each file is being read.
How can I find the values to use when updating the progress bar? I am using
a StreamReader to read the files and whenever I start working on a new file I
set the progress bar's maximum value to sr.BaseStream.Length. Then, I was
going to increment the progress bar as I read each line (by the size of the
line). I am reading each line like so:
using (StreamReader sr = new StreamReader(file))
{
while((line = sr.ReadLine()) != null)
{
...
}
}
I don't know how to find the number of bytes of that line though. I took
the number of chars in the line and divided by two (a char is 2 bytes right?)
but it doesn't add up to the number of bytes returned by the stream length
property. Does BaseStream.Length contain some extra information?
Is this even the right way to do it?
Any tips are appreciated.
Thanks,
-Flack
I am reading a number of files in a directory and doing some work after
reading each line of the file. What I want to have is a progress bar that
gets updated as each file is being read.
How can I find the values to use when updating the progress bar? I am using
a StreamReader to read the files and whenever I start working on a new file I
set the progress bar's maximum value to sr.BaseStream.Length. Then, I was
going to increment the progress bar as I read each line (by the size of the
line). I am reading each line like so:
using (StreamReader sr = new StreamReader(file))
{
while((line = sr.ReadLine()) != null)
{
...
}
}
I don't know how to find the number of bytes of that line though. I took
the number of chars in the line and divided by two (a char is 2 bytes right?)
but it doesn't add up to the number of bytes returned by the stream length
property. Does BaseStream.Length contain some extra information?
Is this even the right way to do it?
Any tips are appreciated.
Thanks,
-Flack