CopyFile() and Progress Bar?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using My.Computer.FileSystem.CopyFile() to copy a bunch of files from
one directoy to another, and would like to display a progress bar on the
screen for each file being copied. Is this possible?
 
brother52 said:
I am using My.Computer.FileSystem.CopyFile() to copy a bunch of files from
one directoy to another, and would like to display a progress bar on the
screen for each file being copied. Is this possible?

I normally use the File.Copy method to copy files and looked into using
a progress meter with it but I could not find a way. I have decided to
eventually write my own File.Copy method that has hooks that will
provide progress meter feedback if desiredm but haven't had the time to
do it yet.

I would be interested if any of the gurus here could offer up
something, maybe someone has already done this.
 
Andrew,

As I see it well than this is all done with Win32 calls, why do that in 2005
while for everything that is needed is managed codes (I assume that not more
is needed than a line of 10).

Cor
 
It is not the same Cor


The VB6 code shows a progress for the file beeing copied


in your scenario you would take the count of the files in the directory as
the progress bars max value
and increment the progressbar by one after every file that is copied


but what if one of the files is 1gb and all the others are a few kb`s ??


regards

Michel Posseth [MCP]
 
Michel,

I assume that I don't have to make a sample for you that you can do that
with the directoryinfo.

http://msdn.microsoft.com/library/d...tml/frlrfsystemiofileinfoclasslengthtopic.asp

It is however what you count as important, in my country we have soon
elections and than they count the votes. Not the weight of a person.

:-)

Cor

Michel Posseth said:
It is not the same Cor


The VB6 code shows a progress for the file beeing copied


in your scenario you would take the count of the files in the directory as
the progress bars max value
and increment the progressbar by one after every file that is copied


but what if one of the files is 1gb and all the others are a few kb`s ??


regards

Michel Posseth [MCP]


Cor Ligthert said:
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/d...html/frlrfsystemiodirectoryinfoclasstopic.asp
than you know how many files you have to copy

And use the File.move than you know the steps in a for each loop
http://msdn2.microsoft.com/en-us/library/system.io.file.move.aspx

Than I don't see what can be the trouble.

So if that does not go, than please reply and tell why

I hope this helps,

Cor
 
I assume that I don't have to make a sample for you that you can do that
with the directoryinfo.

Ofcourse you can do this , however it requires a lot more coding as a few
lines , to emulate the API WIN32 method

And as i do not know your expertise in VB6 i mentioned that the VB6 code did
something else as i think you thought it does
as i said the VB6 code gives a progress callback during the copy of a file
so you get the progress of the file actually beeing copied

same as you copy a large file in Windows ( you will see a progressbar of the
copy process for this one file )

It is however what you count as important, in my country we have soon
elections and than they count the votes. Not the weight of a person.

yes i know i live in the same country ,,,,, i wish they would choose on
quality instead of looks

but nevertheless ,,, i think it is important if you show a progress that the
user is understanding that something is actually hapening if you would go
for a file count
instead of file size to determine the progress of your copy process you will
end up with a seeming to be unresponsive app when you have large files to
copy

just my opinion

regards

Michel Posseth [MCP]




Cor Ligthert said:
Michel,

I assume that I don't have to make a sample for you that you can do that
with the directoryinfo.

http://msdn.microsoft.com/library/d...tml/frlrfsystemiofileinfoclasslengthtopic.asp

It is however what you count as important, in my country we have soon
elections and than they count the votes. Not the weight of a person.

:-)

Cor

Michel Posseth said:
It is not the same Cor


The VB6 code shows a progress for the file beeing copied


in your scenario you would take the count of the files in the directory
as the progress bars max value
and increment the progressbar by one after every file that is copied


but what if one of the files is 1gb and all the others are a few kb`s ??


regards

Michel Posseth [MCP]


Cor Ligthert said:
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/d...html/frlrfsystemiodirectoryinfoclasstopic.asp
than you know how many files you have to copy

And use the File.move than you know the steps in a for each loop
http://msdn2.microsoft.com/en-us/library/system.io.file.move.aspx

Than I don't see what can be the trouble.

So if that does not go, than please reply and tell why

I hope this helps,

Cor


"brother52" <[email protected]> schreef in bericht
I am using My.Computer.FileSystem.CopyFile() to copy a bunch of files
from
one directoy to another, and would like to display a progress bar on
the
screen for each file being copied. Is this possible?
 
Michel

My deeper reason is that I don't know which calls are still usable in WinFX.

And it is still semblance. If there is a process started meanwhile that eats
the processor than that progressbar says nothing. The only reason that it
has to show to the user is something. "It is still busy and somewhere half
or almost at the endpoint.

I know that you live in Rotterdam you would know that (works but whatever).

:-)

Cor

Michel Posseth said:
I assume that I don't have to make a sample for you that you can do that
with the directoryinfo.

Ofcourse you can do this , however it requires a lot more coding as a few
lines , to emulate the API WIN32 method

And as i do not know your expertise in VB6 i mentioned that the VB6 code
did something else as i think you thought it does
as i said the VB6 code gives a progress callback during the copy of a file
so you get the progress of the file actually beeing copied

same as you copy a large file in Windows ( you will see a progressbar of
the copy process for this one file )

It is however what you count as important, in my country we have soon
elections and than they count the votes. Not the weight of a person.

yes i know i live in the same country ,,,,, i wish they would choose on
quality instead of looks

but nevertheless ,,, i think it is important if you show a progress that
the user is understanding that something is actually hapening if you would
go for a file count
instead of file size to determine the progress of your copy process you
will end up with a seeming to be unresponsive app when you have large
files to copy

just my opinion

regards

Michel Posseth [MCP]




Cor Ligthert said:
Michel,

I assume that I don't have to make a sample for you that you can do that
with the directoryinfo.

http://msdn.microsoft.com/library/d...tml/frlrfsystemiofileinfoclasslengthtopic.asp

It is however what you count as important, in my country we have soon
elections and than they count the votes. Not the weight of a person.

:-)

Cor

Michel Posseth said:
It is not the same Cor


The VB6 code shows a progress for the file beeing copied


in your scenario you would take the count of the files in the directory
as the progress bars max value
and increment the progressbar by one after every file that is copied


but what if one of the files is 1gb and all the others are a few kb`s ??


regards

Michel Posseth [MCP]


"Cor Ligthert [MVP]" <[email protected]> schreef in bericht
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/d...html/frlrfsystemiodirectoryinfoclasstopic.asp
than you know how many files you have to copy

And use the File.move than you know the steps in a for each loop
http://msdn2.microsoft.com/en-us/library/system.io.file.move.aspx

Than I don't see what can be the trouble.

So if that does not go, than please reply and tell why

I hope this helps,

Cor


"brother52" <[email protected]> schreef in bericht
I am using My.Computer.FileSystem.CopyFile() to copy a bunch of files
from
one directoy to another, and would like to display a progress bar on
the
screen for each file being copied. Is this possible?
 
brother52 said:
I am using My.Computer.FileSystem.CopyFile() to copy a bunch of files from
one directoy to another, and would like to display a progress bar on the
screen for each file being copied. Is this possible?

Yes, check out the method's overloads. At least one of them has a parameter
that can be used to enable progress dialogs.
 
My.Computer.FileSystem.CopyFile("C:\bigfile.bin", "c:\bck\bigfile.bin",
FileIO.UIOption.AllDialogs)


this will show the standard windows filecopy dialog , please note that
windows determines itself if a dialog show is necesary


m.posseth
 
Back
Top