PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET CopyFile() and Progress Bar?

Reply

CopyFile() and Progress Bar?

 
Thread Tools Rate Thread
Old 05-07-2006, 03:07 PM   #1
=?Utf-8?B?YnJvdGhlcjUy?=
Guest
 
Posts: n/a
Default CopyFile() and Progress Bar?


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?
  Reply With Quote
Old 05-07-2006, 03:49 PM   #2
zacks@construction-imaging.com
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?


brother52 wrote:
> 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.

  Reply With Quote
Old 05-07-2006, 04:04 PM   #3
Andrew Morton
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

brother52 wrote:
> 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?


http://vbnet.mvps.org/index.html?co...kupcallback.htm

Andrew


  Reply With Quote
Old 05-07-2006, 04:38 PM   #4
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/d...oclasstopic.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/li....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" <brother52@discussions.microsoft.com> schreef in bericht
news:8EC4A467-B3E4-40C2-80CB-B6E515D95664@microsoft.com...
>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?



  Reply With Quote
Old 05-07-2006, 04:39 PM   #5
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

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

"Andrew Morton" <akm@in-press.co.uk.invalid> schreef in bericht
news:OehuFUEoGHA.4432@TK2MSFTNGP05.phx.gbl...
> brother52 wrote:
>> 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?

>
> http://vbnet.mvps.org/index.html?co...kupcallback.htm
>
> Andrew
>



  Reply With Quote
Old 05-07-2006, 05:10 PM   #6
zacks@construction-imaging.com
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?


Andrew Morton wrote:
> brother52 wrote:
> > 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?

>
> http://vbnet.mvps.org/index.html?co...kupcallback.htm
>


I'm sure this will work, but it is riddled with API calls. I would
personally prefer it if it used .NET methodology

  Reply With Quote
Old 05-07-2006, 06:14 PM   #7
Michel Posseth [MCP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?


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]" <notmyfirstname@planet.nl> schreef in bericht
news:%23maxZjEoGHA.1592@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> If you use instead of that the
>
> DirectoryInfo
> http://msdn.microsoft.com/library/d...oclasstopic.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/li....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" <brother52@discussions.microsoft.com> schreef in bericht
> news:8EC4A467-B3E4-40C2-80CB-B6E515D95664@microsoft.com...
>>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?

>
>



  Reply With Quote
Old 05-07-2006, 07:35 PM   #8
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

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...lengthtopic.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 [MCP]" <MSDN@posseth.com> schreef in bericht
news:OWYCuZFoGHA.3348@TK2MSFTNGP03.phx.gbl...
>
> 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]" <notmyfirstname@planet.nl> schreef in bericht
> news:%23maxZjEoGHA.1592@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> If you use instead of that the
>>
>> DirectoryInfo
>> http://msdn.microsoft.com/library/d...oclasstopic.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/li....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" <brother52@discussions.microsoft.com> schreef in bericht
>> news:8EC4A467-B3E4-40C2-80CB-B6E515D95664@microsoft.com...
>>>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?

>>
>>

>
>



  Reply With Quote
Old 05-07-2006, 09:14 PM   #9
Michel Posseth [MCP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

> 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 [MVP]" <notmyfirstname@planet.nl> schreef in bericht
news:%23JHDhGGoGHA.4124@TK2MSFTNGP03.phx.gbl...
> 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...lengthtopic.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 [MCP]" <MSDN@posseth.com> schreef in bericht
> news:OWYCuZFoGHA.3348@TK2MSFTNGP03.phx.gbl...
>>
>> 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]" <notmyfirstname@planet.nl> schreef in bericht
>> news:%23maxZjEoGHA.1592@TK2MSFTNGP04.phx.gbl...
>>> Hi,
>>>
>>> If you use instead of that the
>>>
>>> DirectoryInfo
>>> http://msdn.microsoft.com/library/d...oclasstopic.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/li....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" <brother52@discussions.microsoft.com> schreef in bericht
>>> news:8EC4A467-B3E4-40C2-80CB-B6E515D95664@microsoft.com...
>>>>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?
>>>
>>>

>>
>>

>
>



  Reply With Quote
Old 05-07-2006, 09:39 PM   #10
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: CopyFile() and Progress Bar?

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 [MCP]" <MSDN@posseth.com> schreef in bericht
news:Onfk39GoGHA.4688@TK2MSFTNGP03.phx.gbl...
>> 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 [MVP]" <notmyfirstname@planet.nl> schreef in bericht
> news:%23JHDhGGoGHA.4124@TK2MSFTNGP03.phx.gbl...
>> 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...lengthtopic.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 [MCP]" <MSDN@posseth.com> schreef in bericht
>> news:OWYCuZFoGHA.3348@TK2MSFTNGP03.phx.gbl...
>>>
>>> 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]" <notmyfirstname@planet.nl> schreef in bericht
>>> news:%23maxZjEoGHA.1592@TK2MSFTNGP04.phx.gbl...
>>>> Hi,
>>>>
>>>> If you use instead of that the
>>>>
>>>> DirectoryInfo
>>>> http://msdn.microsoft.com/library/d...oclasstopic.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/li....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" <brother52@discussions.microsoft.com> schreef in bericht
>>>> news:8EC4A467-B3E4-40C2-80CB-B6E515D95664@microsoft.com...
>>>>>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?
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off