|
-
Dec 10th, 2005, 11:52 AM
#1
Thread Starter
PowerPoster
progress bar update?
Hi there.
I would like to know exactly how to go about creating a progress bar showing the "transfer" complete progress?
Basically, my app connects to an FTP and downloads a file. Objects are created locally to identify what the file is, if its a directory, what the size is of the file and so on...
I know I have to create a thread for the progress bar to avoid the UI from "hanging".
I pretty much have a progress bar on the form, and have made a method/thread to "Do" the progress bar update.
The thread gets created/called when the file it about to be downloaded.
But now what? How do I make the progress bar show almost "truely" or in sync or whatever, how much of the file has been downloaded?
do I set the maximum property of the progress bar to the size of the file to be downloaded?
then what?
-
Dec 10th, 2005, 12:30 PM
#2
Re: progress bar update?
What is your code for downloading like? Is it something that updates at regular intervals, or a thread that is started and nothing happens until the file is finished?
Bill
-
Dec 10th, 2005, 01:03 PM
#3
Thread Starter
PowerPoster
Re: progress bar update?
don't worry about the code when downloading... i dont really think that has any "integration" with the progress well it may do only when writing to a stream.....
im using .NET 2.0
im just using an FTP Request to download the file, it is then reading it and writing it to a BinaryReader/Writer stream
-
Dec 10th, 2005, 08:30 PM
#4
Thread Starter
PowerPoster
Re: progress bar update?
Well i hope someone can help
I pretty much did it my way - whilst it is reading the buffer, it writes to file and sets the step value to the buffer count.
cool, all works
now trying to find a way of finding the % so I can display that to the user, either using the progress value's properties (which will have the maximum value > 100) or some other calc...
Last edited by Techno; Dec 11th, 2005 at 12:22 AM.
-
Dec 11th, 2005, 07:32 AM
#5
Re: progress bar update?
Take a look at the two links I posted in this thread to see if they help you.
-
Dec 11th, 2005, 08:01 AM
#6
Thread Starter
PowerPoster
Re: progress bar update?
unfortunatly not I already had a look 
code:
Code:
byte[] buffer = new byte[2048];
int count = theBinReader.Read(buffer, 0, buffer.Length);
this.SetStepProgValue(count);
this.DoStepProgValue();
while (count != 0)
{
theBinWriter.Write(buffer, 0, count);
count = theBinReader.Read(buffer, 0, buffer.Length);
this.SetStepProgValue(count);
this.DoStepProgValue();
}
-
Dec 11th, 2005, 11:07 AM
#7
Thread Starter
PowerPoster
Re: progress bar update?
done!
calculate_percent = count * 100 / theFileSize
where count = the stream reader read
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|