![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Maximum property of ProgressBar Hi, I need advice on how to set the maximum property of my progress bar. I read a huge file so I need a progress bar when I read it. However, I don't know how many records are there in the file until I finish reading it. Anyone can advise me on how to set accurate maximum? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Maximum property of ProgressBar On Mon, 2 Jun 2008 13:32:39 -0700 (PDT), Curious <fir5tsight@xxxxxx> wrote: Quote: >Hi, > >I need advice on how to set the maximum property of my progress bar. > >I read a huge file so I need a progress bar when I read it. However, I >don't know how many records are there in the file until I finish >reading it. > >Anyone can advise me on how to set accurate maximum? > >Thanks! track of how many bytes you have read. Don't forget about the record delimiter, which you may not see depending on how you read the file. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Maximum property of ProgressBar Curious, I expect that you are talking about a text file, which is in fact fysical a long string of characters. In those are often CR or/and LF characters, but those can only be seen as they are readed, and that is not your goal. So see the solution from Jack as a very good alternative. Cor "Curious" <fir5tsight@xxxxxx> schreef in bericht news:f763eac4-8312-43db-979b-09adeedf6c60@xxxxxx Quote: > Hi, > > I need advice on how to set the maximum property of my progress bar. > > I read a huge file so I need a progress bar when I read it. However, I > don't know how many records are there in the file until I finish > reading it. > > Anyone can advise me on how to set accurate maximum? > > Thanks! |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Maximum property of ProgressBar On Jun 2, 5:13*pm, Jack Jackson <jjack...@xxxxxx> wrote: Quote: > On Mon, 2 Jun 2008 13:32:39 -0700 (PDT), Curious > > <fir5tsi...@xxxxxx> wrote: Quote: > >Hi, Quote: > >I need advice on how to set the maximum property of my progress bar. Quote: > >I read a huge file so I need a progress bar when I read it. However, I > >don't know how many records are there in the file until I finish > >reading it. Quote: > >Anyone can advise me on how to set accurate maximum? Quote: > >Thanks! > How about finding out the size of the file in bytes, then keeping > track of how many bytes you have read. *Don't forget about the record > delimiter, which you may not see depending on how you read the file. Thanks for the suggestion! Definitely this is do-able although I'll need to calculate the number of bytes I have read in the loop. Could you tell me how to calculate the number of bytes for each line of string? |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Maximum property of ProgressBar On Tue, 3 Jun 2008 07:36:10 -0700 (PDT), Curious <fir5tsight@xxxxxx> wrote: Quote: >On Jun 2, 5:13*pm, Jack Jackson <jjack...@xxxxxx> wrote: Quote: >> On Mon, 2 Jun 2008 13:32:39 -0700 (PDT), Curious >> >> <fir5tsi...@xxxxxx> wrote: Quote: >> >Hi, Quote: >> >I need advice on how to set the maximum property of my progress bar. Quote: >> >I read a huge file so I need a progress bar when I read it. However, I >> >don't know how many records are there in the file until I finish >> >reading it. Quote: >> >Anyone can advise me on how to set accurate maximum? Quote: >> >Thanks! >> How about finding out the size of the file in bytes, then keeping >> track of how many bytes you have read. *Don't forget about the record >> delimiter, which you may not see depending on how you read the file. >Hi Jack, > >Thanks for the suggestion! Definitely this is do-able although I'll >need to calculate the number of bytes I have read in the loop. > >Could you tell me how to calculate the number of bytes for each line >of string? in a string variable. If so, then var.Length is the number of chars. If the method you use to read the lines hides the line termination characters, you need to count them too. I think I would assume two termination characters per line, but check for the count getting too high in case there is only one termination character. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Maximum property of ProgressBar Is var.Length a number of bytes? Or is there a formula to translate number of chars to number of bytes? I assume that I'll need a huge string to hold the entire content of the file in order to get the number of maximum bytes before reading? |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Maximum property of ProgressBar On Tue, 3 Jun 2008 12:02:40 -0700 (PDT), Curious <fir5tsight@xxxxxx> wrote: Quote: >Is var.Length a number of bytes? Or is there a formula to translate >number of chars to number of bytes? > >I assume that I'll need a huge string to hold the entire content of >the file in order to get the number of maximum bytes before reading? I presumed that if you are reading a file, you could find out the size of the file from the file system (System.IO.FileInfo). If the file is Ascii, then the number of bytes in the file will be the same as the number of characters you read plus the number of record delimiters. If the file is Unicode, then the number of bytes will be twice the number of characters. I'm not sure how to determine that. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Maximum property of ProgressBar > Quote: > If the file is Unicode, then the number of bytes will be twice the > number of characters. I'm not sure how to determine that. and the progress, the absolute values are not relevant. :-) Cor |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Maximum property of ProgressBar On Wed, 4 Jun 2008 06:14:55 +0200, "Cor Ligthert[MVP]" <notmyfirstname@xxxxxx> wrote: Quote: Quote: >> >> If the file is Unicode, then the number of bytes will be twice the >> number of characters. I'm not sure how to determine that. >Which is absolute not important for your solution, it is about the length >and the progress, the absolute values are not relevant. > >:-) > >Cor Suppose the file contains 1000 bytes. If the file contains Ascii characters, then (ignoring line ending characters) the program will read 1000 characters. If the file contains Unicode characters, then if the program reads the file correctly (each Unicode character in the file becomes one string character) the program will read 500 characters. If the program doesn't deal with this, the progress bar will only go to 50%. |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Maximum property of ProgressBar Hi Jack, Thanks for the suggestion on using System.IO.FileInfo! It solved my problem. At first, I get the length of the entire content of the file by using System.IO.FileInfo. Then I read in the first line and get its length. Then I divided the length of the entire content by the length of the first line and come up with the count as mProgressBar.Maximum. Since all of the lines are not precisely the same length, in order to prevent mProgressBar.Value exceeding mProgressBar.Maximum, I check this each time when I set mProgressBar.Value. FYI, the characters are Ascii. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Help display ProgressBar while ChildForm loads | .NET General | |||
| Set Focus To Specific Property In Property Grid | .NET General | |||
| How Much Maximum RAM you Use? | Vista General | |||