Progress Bar: File Copy
-
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.
-
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.
-
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.
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...
-
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.
Hello Pardon me for asking this intuitive question, but... How do you copy your file exactly??:-D
Regards:rose:
-
Hello Pardon me for asking this intuitive question, but... How do you copy your file exactly??:-D
Regards:rose:
-
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...
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 ::.
-
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 ::.
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...
-
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.
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.
-
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: