Problem with Progress Bar
-
I have a problem : Description of problem: When I use coding to copy a large file like 700MB to a different location. It takes upto 5 minutes. So I want to show some continues working Progress Bar. But when it starts copy process all the activities hanged. No Progress bar visible at that time. Please give any solution.
-
I have a problem : Description of problem: When I use coding to copy a large file like 700MB to a different location. It takes upto 5 minutes. So I want to show some continues working Progress Bar. But when it starts copy process all the activities hanged. No Progress bar visible at that time. Please give any solution.
You need to copy the file on a different thread. You should use the Background Worker class, but it is only available in .Net 2.0. Link for creating Background worker in .Net 1.1 http://www.devx.com/codemag/Article/20639?trk=DXRSS\_DOTNET How to use the Background worker in .Net 2.0 http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx VB6.0 Don't think it is easily possible.
Mike Lasseter
-
I have a problem : Description of problem: When I use coding to copy a large file like 700MB to a different location. It takes upto 5 minutes. So I want to show some continues working Progress Bar. But when it starts copy process all the activities hanged. No Progress bar visible at that time. Please give any solution.
-
I have a problem : Description of problem: When I use coding to copy a large file like 700MB to a different location. It takes upto 5 minutes. So I want to show some continues working Progress Bar. But when it starts copy process all the activities hanged. No Progress bar visible at that time. Please give any solution.
Well, you've got a bit of a problem. Just putting a ProgressBar on a form doesn't do anything. You have to update it with, well, progress. If you're using the
File.Copy
method, you'll never get that progress. It's a blocking call that doesn't report anything during the copy. In order to make a progress bar work, you have to copy the file yourself using file stream methods. You know...open a file read some of it, write that to another file. Well, that's where you update the ProgressBar. You get the size of the file first, start copying the file, track how much of the file you've copied and update the ProgressBar as you're copying the file. Like the others have said, you can even move the copy operation to another thread so your UI stays responsive.Dave Kreskowiak Microsoft MVP - Visual Basic