Results 1 to 7 of 7

Thread: progress bar update?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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?

  2. #2
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    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
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: progress bar update?

    Take a look at the two links I posted in this thread to see if they help you.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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();
                    }

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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
  •  



Click Here to Expand Forum to Full Width