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. file copy progress bar

file copy progress bar

Scheduled Pinned Locked Moved C#
tutorialquestion
11 Posts 5 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 numbers1thru9

    Ive been trying to find an example on how to make a progress bar progress with the copying of a file using the copyTo command. does anyone know how to make it work?

    J Offline
    J Offline
    Judah Gabriel Himango
    wrote on last edited by
    #2

    You won't be able to do a real progress bar with File.Copy because it is synchronous and does not give any feedback as to the overall progress of the operation. You could easily do this yourself, however. Open the file you want to copy, and create a destination file you want to copy the file to. Read in the source file byte-by-byte, and write those bytes to the destination file. Every few bytes, raise an event indicating the overall progress of the operation. Interested components would simply listen to that event and could update the value of a progress bar if they wanted.

    Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

    N M 2 Replies Last reply
    0
    • J Judah Gabriel Himango

      You won't be able to do a real progress bar with File.Copy because it is synchronous and does not give any feedback as to the overall progress of the operation. You could easily do this yourself, however. Open the file you want to copy, and create a destination file you want to copy the file to. Read in the source file byte-by-byte, and write those bytes to the destination file. Every few bytes, raise an event indicating the overall progress of the operation. Interested components would simply listen to that event and could update the value of a progress bar if they wanted.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

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

      How would I go about doing this? Im still pretty new to C# and havent learned alot of things yet

      J 1 Reply Last reply
      0
      • N numbers1thru9

        How would I go about doing this? Im still pretty new to C# and havent learned alot of things yet

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #4

        Go about reading and writing to files, bytes at a time? Have a look at the basic file I/O document[^] on MSDN.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

        1 Reply Last reply
        0
        • J Judah Gabriel Himango

          You won't be able to do a real progress bar with File.Copy because it is synchronous and does not give any feedback as to the overall progress of the operation. You could easily do this yourself, however. Open the file you want to copy, and create a destination file you want to copy the file to. Read in the source file byte-by-byte, and write those bytes to the destination file. Every few bytes, raise an event indicating the overall progress of the operation. Interested components would simply listen to that event and could update the value of a progress bar if they wanted.

          Tech, life, family, faith: Give me a visit. I'm currently blogging about: And in this corner, the Party of Allah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

          M Offline
          M Offline
          Mrguoxiang
          wrote on last edited by
          #5

          Up

          I am a chinese I love my country.

          1 Reply Last reply
          0
          • N numbers1thru9

            Ive been trying to find an example on how to make a progress bar progress with the copying of a file using the copyTo command. does anyone know how to make it work?

            E Offline
            E Offline
            ekynox
            wrote on last edited by
            #6

            there is a much simpler option. Simply add the reference, Microsoft.VisualBasic dll to your c# references project. Within the Microsoft.VisualBasic dll is the VB.NET file copy routine which displays a copy progress dialog much like the windows one. Here is an example. Microsoft.VisualBasic.FileIO.FileSystem.CopyFile("c:\helloworld.txt","c:\temp\helloworld.txt",UIOption.AllDialogs,UICancelOption.DoNothing);

            C N 2 Replies Last reply
            0
            • E ekynox

              there is a much simpler option. Simply add the reference, Microsoft.VisualBasic dll to your c# references project. Within the Microsoft.VisualBasic dll is the VB.NET file copy routine which displays a copy progress dialog much like the windows one. Here is an example. Microsoft.VisualBasic.FileIO.FileSystem.CopyFile("c:\helloworld.txt","c:\temp\helloworld.txt",UIOption.AllDialogs,UICancelOption.DoNothing);

              C Offline
              C Offline
              Coding C
              wrote on last edited by
              #7

              Hi, i tried ur way but cought in probs. i gives me with error "the type or namespace name 'FileIO' does not exists in the class or namespace 'microsoft.visualbasic' (are you missing ans assembly reference?)" i have also included the reference in the project of microsoft.visualbasic dont know wats the prob. can u help? Nitin...

              E 1 Reply Last reply
              0
              • C Coding C

                Hi, i tried ur way but cought in probs. i gives me with error "the type or namespace name 'FileIO' does not exists in the class or namespace 'microsoft.visualbasic' (are you missing ans assembly reference?)" i have also included the reference in the project of microsoft.visualbasic dont know wats the prob. can u help? Nitin...

                E Offline
                E Offline
                ekynox
                wrote on last edited by
                #8

                Are you using visual studio 2005? As it works for me under that IDE. Apart from that I cant work out what could be your problem.

                C 1 Reply Last reply
                0
                • E ekynox

                  Are you using visual studio 2005? As it works for me under that IDE. Apart from that I cant work out what could be your problem.

                  C Offline
                  C Offline
                  Coding C
                  wrote on last edited by
                  #9

                  Hi, thanx for reply. no i m not using vs2005. i am using vs2003. can u help. thanx Nitin...

                  E 1 Reply Last reply
                  0
                  • C Coding C

                    Hi, thanx for reply. no i m not using vs2005. i am using vs2003. can u help. thanx Nitin...

                    E Offline
                    E Offline
                    ekynox
                    wrote on last edited by
                    #10

                    go buy a copy of visual studio 2005.

                    1 Reply Last reply
                    0
                    • E ekynox

                      there is a much simpler option. Simply add the reference, Microsoft.VisualBasic dll to your c# references project. Within the Microsoft.VisualBasic dll is the VB.NET file copy routine which displays a copy progress dialog much like the windows one. Here is an example. Microsoft.VisualBasic.FileIO.FileSystem.CopyFile("c:\helloworld.txt","c:\temp\helloworld.txt",UIOption.AllDialogs,UICancelOption.DoNothing);

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

                      This sounds like a good option, except the progress bar I am using is in the status strip instead of a dialog box

                      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