473,396 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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?
Jul 5 '06 #1
11 5186

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.

Jul 5 '06 #2
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?cod...upcallback.htm

Andrew
Jul 5 '06 #3
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/de...classtopic.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/lib...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" <br*******@discussions.microsoft.comschreef in bericht
news:8E**********************************@microsof t.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?

Jul 5 '06 #4
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" <ak*@in-press.co.uk.invalidschreef in bericht
news:Oe**************@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?cod...upcallback.htm

Andrew

Jul 5 '06 #5

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?cod...upcallback.htm
I'm sure this will work, but it is riddled with API calls. I would
personally prefer it if it used .NET methodology

Jul 5 '06 #6

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]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/de...classtopic.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/lib...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" <br*******@discussions.microsoft.comschreef in bericht
news:8E**********************************@microsof t.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?


Jul 5 '06 #7
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/de...engthtopic.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]" <MS**@posseth.comschreef in bericht
news:OW**************@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]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/de...classtopic.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/lib...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" <br*******@discussions.microsoft.comschreef in bericht
news:8E**********************************@microso ft.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?



Jul 5 '06 #8
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]" <no************@planet.nlschreef in bericht
news:%2****************@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/de...engthtopic.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]" <MS**@posseth.comschreef in bericht
news:OW**************@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]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/de...classtopic.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/lib...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" <br*******@discussions.microsoft.comschreef in bericht
news:8E**********************************@micros oft.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?




Jul 5 '06 #9
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]" <MS**@posseth.comschreef in bericht
news:On**************@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]" <no************@planet.nlschreef in bericht
news:%2****************@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/de...engthtopic.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]" <MS**@posseth.comschreef in bericht
news:OW**************@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]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
Hi,

If you use instead of that the

DirectoryInfo
http://msdn.microsoft.com/library/de...classtopic.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/lib...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" <br*******@discussions.microsoft.comschreef in bericht
news:8E**********************************@micro soft.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?




Jul 5 '06 #10
"brother52" <br*******@discussions.microsoft.comschrieb:
>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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 5 '06 #11

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


"Herfried K. Wagner [MVP]" wrote:
"brother52" <br*******@discussions.microsoft.comschrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 6 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ad | last post by:
I am finding to copyfile in the online document. But I only find the namespace : Namespace: Microsoft.VisualBasic.FileIO How can I copyfile in c#?
2
by: manuelg | last post by:
Here is a code fragment, where I am trying to copy a file, avoiding overwrites and race conditions. The filename gets a '02','03','04' etc appended to the end if a file with that name already...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
0
by: rij | last post by:
I am using CopyFile to copy a file from the local/client PC to a Server Share but i get "Permission Denied". I can see the source file (FileExists) but can not write to the desination. I have...
1
by: Hugo Ferreira | last post by:
Hi there, I have a problem. I'm using calling shutil.copyfile() followed by open(). The thing is that most of the times open() is called before the actual file is copied. I don't have this...
10
by: Robert Dailey | last post by:
Hi, I'm trying to create a Python equivalent of the C++ "ifstream" class, with slight behavior changes. Basically, I want to have a "filestream" object that will allow you to overload the...
0
by: Ahmed, Shakir | last post by:
Is there any way to copy a file from src to dst if the dst is exclusively open by other users. I am using src = 'c:\mydata\data\*.mdb' dst = 'v:\data\all\*.mdb' shutil.copyfile(src,dst)
2
by: Lance Hoffmeyer | last post by:
Hey all, As always, thanks in advance! I am trying to save a ppt presentation but am having problems regarding spaces and am wondering if I am doing something wrong or whether this is a bug?...
1
by: Ahmed, Shakir | last post by:
Need help to copy a personal geodatabase from one location to another: Trying to copy a personal geodatabase from one location to another location where all the users are retrieving data from...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.