Home All Groups Group Topic Archive Search About

Copy files and progressbar

Author
7 Mar 2006 7:26 PM
Reidar
I want to copy a file from a server to a local machine.
The process should be shown displayed by a progressbar.
Has anybody an example of this?
reidarT

Author
7 Mar 2006 9:39 PM
zacks
You may not get much of a response as both working a progress bar
control and copying a file, at least with the  File.Copy method are
both so absurdly simple, no one will bother to help. And if you do use
the FileCopy method to copy the file there ain't no way in hell you can
hook a progress bar to it (if there is some way, I'd love to hear
it!!).

To hook a file copy operation to a progress bar you are going to have
to read a chunk of the file with some File Reader mechanism (there are
a couple, look up FileReader class and FileStream class), update the
progress bar, and write the chunk out to the new file. If the file is
binary, you will need to hook a BinaryReader to your input stream and a
BinaryWriter to your output stream. All this is covered pretty well by
the help text.
Author
8 Mar 2006 10:06 AM
voorreclame
za***@construction-imaging.com schreef:

Show quoteHide quote
> You may not get much of a response as both working a progress bar
> control and copying a file, at least with the  File.Copy method are
> both so absurdly simple, no one will bother to help. And if you do use
> the FileCopy method to copy the file there ain't no way in hell you can
> hook a progress bar to it (if there is some way, I'd love to hear
> it!!).
>
> To hook a file copy operation to a progress bar you are going to have
> to read a chunk of the file with some File Reader mechanism (there are
> a couple, look up FileReader class and FileStream class), update the
> progress bar, and write the chunk out to the new file. If the file is
> binary, you will need to hook a BinaryReader to your input stream and a
> BinaryWriter to your output stream. All this is covered pretty well by
> the help text.

A time ago I found this URL, it's probably just what you need:
http://khsw.blogspot.com/2005/08/copy-file-with-progressbar-in-vbnet.html
Author
8 Mar 2006 2:48 PM
zacks
That was some interesting code. I do not like calling APIs directly
from .NET code, but I suppose sometimes it's necessary. And writing a
class wrapper around them and make them look .NETish would be
acceptable.