Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Progress Bar: File Copy

Progress Bar: File Copy

Scheduled Pinned Locked Moved C#
help
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    numbers1thru9
    wrote on last edited by
    #1

    Ive been trying to figure this problem out. I have a status strip with a progress bar in it. I want to use that pb to increase as the file is copying. Someone suggested I have an event that occurs every few bytes or so to increase the pb. I have looked and looked for a way to do this only to return to not have anything. Any help or a link that can do this would be greatly appreciated. Thanks.

    P M N N 4 Replies Last reply
    0
    • N numbers1thru9

      Ive been trying to figure this problem out. I have a status strip with a progress bar in it. I want to use that pb to increase as the file is copying. Someone suggested I have an event that occurs every few bytes or so to increase the pb. I have looked and looked for a way to do this only to return to not have anything. Any help or a link that can do this would be greatly appreciated. Thanks.

      P Offline
      P Offline
      pasha2k
      wrote on last edited by
      #2

      try to use the Refresh() method for your progress bar after each PerformStep() regards..

      .:: Something is Wrong ::.

      1 Reply Last reply
      0
      • N numbers1thru9

        Ive been trying to figure this problem out. I have a status strip with a progress bar in it. I want to use that pb to increase as the file is copying. Someone suggested I have an event that occurs every few bytes or so to increase the pb. I have looked and looked for a way to do this only to return to not have anything. Any help or a link that can do this would be greatly appreciated. Thanks.

        M Offline
        M Offline
        mav northwind
        wrote on last edited by
        #3

        With BCL classes you're out of luck here. The built-in classes don't give you any progress update while copying. You can either write your own file copy routine that's firing an event from time to time or p/invoke CopyFileEx.

        Regards, mav -- Black holes are the places where god divided by 0...

        P 1 Reply Last reply
        0
        • N numbers1thru9

          Ive been trying to figure this problem out. I have a status strip with a progress bar in it. I want to use that pb to increase as the file is copying. Someone suggested I have an event that occurs every few bytes or so to increase the pb. I have looked and looked for a way to do this only to return to not have anything. Any help or a link that can do this would be greatly appreciated. Thanks.

          N Offline
          N Offline
          Nader Elshehabi
          wrote on last edited by
          #4

          Hello Pardon me for asking this intuitive question, but... How do you copy your file exactly??:-D

          Regards:rose:

          P 1 Reply Last reply
          0
          • N Nader Elshehabi

            Hello Pardon me for asking this intuitive question, but... How do you copy your file exactly??:-D

            Regards:rose:

            P Offline
            P Offline
            pasha2k
            wrote on last edited by
            #5

            .. using System.IO; .. .. File.Copy(source,destination); .. ..

            .:: Something is Wrong ::.

            N 1 Reply Last reply
            0
            • M mav northwind

              With BCL classes you're out of luck here. The built-in classes don't give you any progress update while copying. You can either write your own file copy routine that's firing an event from time to time or p/invoke CopyFileEx.

              Regards, mav -- Black holes are the places where god divided by 0...

              P Offline
              P Offline
              pasha2k
              wrote on last edited by
              #6

              In my app, Refresh() does the job.. But you can also try .. .. //after a specific amount of bytes are copied UpdateProgressBar(); .. .. public delegate void UpdateDelegate(); private void UpdateProgressBar() { if (statusToolStrip.invokeRequired) { UpdateDelegate delegate = new UpdateDelegate(); delegate.Invoke(UpdateProgressBar); } else { progressBar.PerformStep(); statusToolStrip.Refresh(); } } .. ..

              .:: Something is Wrong ::.

              M 1 Reply Last reply
              0
              • P pasha2k

                In my app, Refresh() does the job.. But you can also try .. .. //after a specific amount of bytes are copied UpdateProgressBar(); .. .. public delegate void UpdateDelegate(); private void UpdateProgressBar() { if (statusToolStrip.invokeRequired) { UpdateDelegate delegate = new UpdateDelegate(); delegate.Invoke(UpdateProgressBar); } else { progressBar.PerformStep(); statusToolStrip.Refresh(); } } .. ..

                .:: Something is Wrong ::.

                M Offline
                M Offline
                mav northwind
                wrote on last edited by
                #7

                That's not the question. How can you update the progress bar when you don't get any progress notification from File.Copy() ?

                Regards, mav -- Black holes are the places where god divided by 0...

                1 Reply Last reply
                0
                • N numbers1thru9

                  Ive been trying to figure this problem out. I have a status strip with a progress bar in it. I want to use that pb to increase as the file is copying. Someone suggested I have an event that occurs every few bytes or so to increase the pb. I have looked and looked for a way to do this only to return to not have anything. Any help or a link that can do this would be greatly appreciated. Thanks.

                  N Offline
                  N Offline
                  numbers1thru9
                  wrote on last edited by
                  #8

                  its not an issue about refreshing, I dont know how to even make it invoke a way to update the pb after so many bytes written. I only know how to copy in general with File.Copy or FileInfo.CopyTo but neither of these provide a way to update a pb after a specified about of bytes and thats what i need to do.

                  1 Reply Last reply
                  0
                  • P pasha2k

                    .. using System.IO; .. .. File.Copy(source,destination); .. ..

                    .:: Something is Wrong ::.

                    N Offline
                    N Offline
                    Nader Elshehabi
                    wrote on last edited by
                    #9

                    Hello Mav is right. Yet!! As my habit of making crazy suggestion;P, you can make a timer that checks the destination file's size each -let's say- 50 milliseconds, and updates the ProgressBar according to the percent of the current size/Total size.

                    Regards:rose:

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups