473,385 Members | 1,919 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,385 software developers and data experts.

show progress while copying big file

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
8 18330
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yxq | last post by:
Hello, When show a string in a fixed extent label control, if this string is too long, then it can not be shown inextenso. How to only show the front and the end of the string, the middle section...
4
by: hzgt9b | last post by:
Usig VB .NET 2003, I'm writing a simple app that copies 1 or more files. Requiremtns state that I need two progress bars one for current file copy progress and one for overall progress. My...
8
by: WhiteWizard | last post by:
I guess it's my turn to ASK a question ;) Briefly my problem: I am developing a Windows app that has several User Controls. On one of these controls, I am copying/processing some rather large...
4
by: Joachim | last post by:
Is there an efficient way of copying a file and at the same time updating a progress bar with short intervals to see how much is still to copy of the file? Like some FTP programs have for instance.
0
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by...
5
hariharanmca
by: hariharanmca | last post by:
i am copying a file which is nearly 10 MB through FileSystemObject. It is a single file, is it possible to show progress bar for that file. Front-End : VB 6.0
6
by: Michael | last post by:
I need to copy a huge file (around 300Mb) from a mapped network drive to another. I have created a console application and used System.IO.File.Copy function. But I want to know the process of...
6
by: kimiraikkonen | last post by:
Hi, I use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar,...
6
by: Johnny Jörgensen | last post by:
Using File.Copy in the System.IO namespace, it's easy to copy one or more files. But I wonder: Is it possible to get windows to display its File Copy Progress dialog at the same time - or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.