Click here to Skip to main content
16,004,977 members
Home / Discussions / C#
   

C#

 
AnswerRe: Disabling MenuItems Pin
dnewmon4-Dec-05 9:47
dnewmon4-Dec-05 9:47 
GeneralRe: Disabling MenuItems Pin
naglbitur4-Dec-05 10:07
naglbitur4-Dec-05 10:07 
GeneralRe: Disabling MenuItems Pin
mav.northwind5-Dec-05 3:10
mav.northwind5-Dec-05 3:10 
GeneralRe: Disabling MenuItems Pin
naglbitur5-Dec-05 7:05
naglbitur5-Dec-05 7:05 
AnswerRe: Disabling MenuItems Pin
mav.northwind5-Dec-05 7:18
mav.northwind5-Dec-05 7:18 
GeneralRe: Disabling MenuItems Pin
naglbitur6-Dec-05 2:06
naglbitur6-Dec-05 2:06 
AnswerRe: Disabling MenuItems Pin
André Ziegler5-Dec-05 4:04
André Ziegler5-Dec-05 4:04 
QuestionBackgroundWorker and ProgressBar Pin
SunsOfFun4-Dec-05 3:57
SunsOfFun4-Dec-05 3:57 
I want to display the status in a ProgressBar when copying large files across the network. I am using FileInfo.CopyTo method within the DoWork Method of the BackgroundWorker class (please see the code below). How am I able to fire events while the copying is taking place to update the ProgressBar. The problem is that the execution enters FileInfo.CopyTo method and does not leave until the process is complete.

Hope this makes sense.

private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) {<br />
         <br />
            BackgroundWorker worker = sender as BackgroundWorker;<br />
            reached = 0;<br />
                fileInfoFrom = new FileInfo(@"C:\Temp\Path1\Test.zip");<br />
                fileInfoTo = new FileInfo(@"C:\Temp\Path2\Test.zip");<br />
<br />
               <br />
                fs = (fileInfoTo.Exists) ? fileInfoTo.Length : 0f;<br />
                fileInfoFrom.CopyTo(@"C:\Temp\Path2\Test.zip", true);<br />
                /* thought about using the file size to <br />
                 * calculate the percentage for the progressbar*/<br />
                int completed =<br />
                    (int)((float)fs / (float)fileInfoFrom.Length * 100);<br />
                if (completed > reached) {<br />
                        reached = completed;<br />
                    worker.ReportProgress(completed);<br />
                }<br />
        }


-- modified at 12:47 Sunday 4th December, 2005
AnswerRe: BackgroundWorker and ProjessBar Pin
Rob Philpott4-Dec-05 4:40
Rob Philpott4-Dec-05 4:40 
GeneralRe: BackgroundWorker and ProjessBar Pin
SunsOfFun4-Dec-05 6:49
SunsOfFun4-Dec-05 6:49 
GeneralRe: BackgroundWorker and ProjessBar Pin
Rob Philpott4-Dec-05 8:09
Rob Philpott4-Dec-05 8:09 
GeneralRe: BackgroundWorker and ProjessBar Pin
SunsOfFun4-Dec-05 19:04
SunsOfFun4-Dec-05 19:04 
GeneralRe: BackgroundWorker and ProjessBar Pin
Rob Philpott4-Dec-05 22:02
Rob Philpott4-Dec-05 22:02 
QuestionAbout encoding setting? Pin
pmasknguyen4-Dec-05 3:34
pmasknguyen4-Dec-05 3:34 
QuestionComboBox question Pin
1nsp1r3d4-Dec-05 1:11
1nsp1r3d4-Dec-05 1:11 
AnswerRe: ComboBox question Pin
Curtis Schlak.4-Dec-05 2:38
Curtis Schlak.4-Dec-05 2:38 
GeneralRe: ComboBox question Pin
1nsp1r3d4-Dec-05 3:36
1nsp1r3d4-Dec-05 3:36 
GeneralRe: ComboBox question Pin
Curtis Schlak.4-Dec-05 11:31
Curtis Schlak.4-Dec-05 11:31 
QuestionUsing Dispose in Classes? Pin
redfish343-Dec-05 23:24
redfish343-Dec-05 23:24 
AnswerRe: Using Dispose in Classes? Pin
Guffa3-Dec-05 23:41
Guffa3-Dec-05 23:41 
AnswerRe: Using Dispose in Classes? Pin
Colin Angus Mackay3-Dec-05 23:42
Colin Angus Mackay3-Dec-05 23:42 
AnswerThanks for Help Pin
redfish344-Dec-05 13:07
redfish344-Dec-05 13:07 
QuestionWhat Does this Code Mean? Pin
redfish343-Dec-05 23:21
redfish343-Dec-05 23:21 
AnswerRe: What Does this Code Mean? Pin
Colin Angus Mackay3-Dec-05 23:44
Colin Angus Mackay3-Dec-05 23:44 
GeneralRe: What Does this Code Mean? Pin
leppie4-Dec-05 2:30
leppie4-Dec-05 2:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.