By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

show progress while copying big file

P: n/a
Hi,

is it possible to show the progress of a big file being copied e.g. in
a "progressbar"?
I tried to use file.copy - but this seems to make no sense :-(

Thanks in advance,

Randy

Nov 16 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
to do a proper progress bar, and provide button to cancel etc. you'll need
to do the file copying in a seperate worker thread.
you can then fire events from there back to your form containing the
progress bar to report progress.

in a nutshell, you need to keep the UI responsive whilst the copying is
taking place.

look in to making a worker thread, it's not too difficult, and then look
into calling control's methods from another thread - this too is easy to do.

HTH
Sam
"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Hi,

is it possible to show the progress of a big file being copied e.g. in
a "progressbar"?
I tried to use file.copy - but this seems to make no sense :-(

Thanks in advance,

Randy

Nov 16 '05 #2

P: n/a
Randy,

If you want to show the standard progress bar, then you will want to
call the SHFileOperation API function through the P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Hi,

is it possible to show the progress of a big file being copied e.g. in
a "progressbar"?
I tried to use file.copy - but this seems to make no sense :-(

Thanks in advance,

Randy

Nov 16 '05 #3

P: n/a
listen to nick, he knows

"Randy" <Ra***@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
Hi,

is it possible to show the progress of a big file being copied e.g. in
a "progressbar"?
I tried to use file.copy - but this seems to make no sense :-(

Thanks in advance,

Randy

Nov 16 '05 #4

P: n/a
Dear All,

i am building a pocket pc program that will be copying a large file
from across a network. I am trying to show a progress bar for the file
being copied
can anyone tell me how to update the progress bar to reflect the
status of the copy process.
I am using system.io.file.copy
Please tell me step by step,

Best regards,

Mohamed Oubouchil
Nov 16 '05 #5

P: n/a
C# not provide solution for this. You can use either Managed FileCopyEx
implementation or SHFileOperation. Refer MSDN for how to

"Mohamed Oubouchil" <ou*******@hotmail.com> wrote in message
news:aa**************************@posting.google.c om...
Dear All,

i am building a pocket pc program that will be copying a large file
from across a network. I am trying to show a progress bar for the file
being copied
can anyone tell me how to update the progress bar to reflect the
status of the copy process.
I am using system.io.file.copy
Please tell me step by step,

Best regards,

Mohamed Oubouchil

Nov 16 '05 #6

P: n/a
I think my question was not clear. Here is a simpler scenario. If I want to
show text "Finished!" on myLabel1 on Form1 from Class1, how should I do it?
If I do this from the code behind of Form1, I can just write myLabel1.Text =
"Finished!", but I don't know how I can do this from Class1.

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:uS****************@TK2MSFTNGP11.phx.gbl...
C# not provide solution for this. You can use either Managed FileCopyEx
implementation or SHFileOperation. Refer MSDN for how to

"Mohamed Oubouchil" <ou*******@hotmail.com> wrote in message
news:aa**************************@posting.google.c om...
Dear All,

i am building a pocket pc program that will be copying a large file
from across a network. I am trying to show a progress bar for the file
being copied
can anyone tell me how to update the progress bar to reflect the
status of the copy process.
I am using system.io.file.copy
Please tell me step by step,

Best regards,

Mohamed Oubouchil


Nov 16 '05 #7

P: n/a
The following example is in your main form. This can be called from your
main form *or from another thread which can be your class1. You just need
to pass the form ref to your class constructor or set a public static or
something so that class1 knows how to reference
"Form.UpdateDelegate("sometext");" (for example.) Note the InvokeRequired
and delegate stuff is there to make any calls from other threads are queued
to UI thread as you should not call UI controls from other threads.
Moreover, you can use this method to update any control in your forms
(pBars, etc.) Just create the right delegate and use the UpdateLabel
template as example for you new method. hth

private delegate void UpdateDelegate(string value);

public void UpdateLabel(string text)
{
if ( text == null )
throw new ArgumentNullException("text");

if ( InvokeRequired )
{
UpdateDelegate ud = new UpdateDelegate(UpdateLabel);
this.BeginInvoke(ud, new object[]{text});
}
else
{
this.label1.Text = text;
}
}

--
William Stacey, MVP
http://mvp.support.microsoft.com

"TomTom" <no*****@nospamfordiscussion.com> wrote in message
news:#q**************@TK2MSFTNGP09.phx.gbl...
I think my question was not clear. Here is a simpler scenario. If I want to show text "Finished!" on myLabel1 on Form1 from Class1, how should I do it? If I do this from the code behind of Form1, I can just write myLabel1.Text = "Finished!", but I don't know how I can do this from Class1.

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:uS****************@TK2MSFTNGP11.phx.gbl...
C# not provide solution for this. You can use either Managed FileCopyEx
implementation or SHFileOperation. Refer MSDN for how to

"Mohamed Oubouchil" <ou*******@hotmail.com> wrote in message
news:aa**************************@posting.google.c om...
Dear All,

i am building a pocket pc program that will be copying a large file
from across a network. I am trying to show a progress bar for the file
being copied
can anyone tell me how to update the progress bar to reflect the
status of the copy process.
I am using system.io.file.copy
Please tell me step by step,

Best regards,

Mohamed Oubouchil




Nov 16 '05 #8

P: n/a
William,

Thank you for the info. This is really helpful.

Tomtom

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
The following example is in your main form. This can be called from your
main form *or from another thread which can be your class1. You just need
to pass the form ref to your class constructor or set a public static or
something so that class1 knows how to reference
"Form.UpdateDelegate("sometext");" (for example.) Note the InvokeRequired
and delegate stuff is there to make any calls from other threads are
queued
to UI thread as you should not call UI controls from other threads.
Moreover, you can use this method to update any control in your forms
(pBars, etc.) Just create the right delegate and use the UpdateLabel
template as example for you new method. hth

private delegate void UpdateDelegate(string value);

public void UpdateLabel(string text)
{
if ( text == null )
throw new ArgumentNullException("text");

if ( InvokeRequired )
{
UpdateDelegate ud = new UpdateDelegate(UpdateLabel);
this.BeginInvoke(ud, new object[]{text});
}
else
{
this.label1.Text = text;
}
}

--
William Stacey, MVP
http://mvp.support.microsoft.com

"TomTom" <no*****@nospamfordiscussion.com> wrote in message
news:#q**************@TK2MSFTNGP09.phx.gbl...
I think my question was not clear. Here is a simpler scenario. If I want

to
show text "Finished!" on myLabel1 on Form1 from Class1, how should I do

it?
If I do this from the code behind of Form1, I can just write
myLabel1.Text

=
"Finished!", but I don't know how I can do this from Class1.

"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:uS****************@TK2MSFTNGP11.phx.gbl...
> C# not provide solution for this. You can use either Managed FileCopyEx
> implementation or SHFileOperation. Refer MSDN for how to
>
> "Mohamed Oubouchil" <ou*******@hotmail.com> wrote in message
> news:aa**************************@posting.google.c om...
>> Dear All,
>>
>> i am building a pocket pc program that will be copying a large file
>> from across a network. I am trying to show a progress bar for the file
>> being copied
>> can anyone tell me how to update the progress bar to reflect the
>> status of the copy process.
>> I am using system.io.file.copy
>> Please tell me step by step,
>>
>> Best regards,
>>
>> Mohamed Oubouchil
>
>


Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.