Click here to Skip to main content
15,894,405 members
Home / Discussions / C#
   

C#

 
AnswerRe: cross thread events Pin
Moreno Airoldi3-Jun-09 0:15
Moreno Airoldi3-Jun-09 0:15 
GeneralRe: cross thread events Pin
harold aptroot3-Jun-09 0:22
harold aptroot3-Jun-09 0:22 
AnswerRe: cross thread events Pin
S. Senthil Kumar3-Jun-09 9:12
S. Senthil Kumar3-Jun-09 9:12 
QuestionProblem with multiple versions of references Pin
vijaylumar2-Jun-09 23:47
vijaylumar2-Jun-09 23:47 
Questionmysql connect + retrieving record Pin
benjamin yap2-Jun-09 23:40
benjamin yap2-Jun-09 23:40 
AnswerRe: mysql connect + retrieving record Pin
Blue_Boy2-Jun-09 23:52
Blue_Boy2-Jun-09 23:52 
AnswerRe: mysql connect + retrieving record Pin
Moreno Airoldi2-Jun-09 23:58
Moreno Airoldi2-Jun-09 23:58 
GeneralRe: mysql connect + retrieving record Pin
benjamin yap3-Jun-09 0:01
benjamin yap3-Jun-09 0:01 
GeneralRe: mysql connect + retrieving record Pin
benjamin yap3-Jun-09 0:07
benjamin yap3-Jun-09 0:07 
GeneralRe: mysql connect + retrieving record Pin
Moreno Airoldi3-Jun-09 0:33
Moreno Airoldi3-Jun-09 0:33 
QuestionControlling Navigation in IE using c# Pin
svt gdwl2-Jun-09 23:38
svt gdwl2-Jun-09 23:38 
AnswerRe: Controlling Navigation in IE using c# Pin
Pete O'Hanlon2-Jun-09 23:54
mvePete O'Hanlon2-Jun-09 23:54 
QuestionCopying a file with progress Pin
musefan2-Jun-09 23:31
musefan2-Jun-09 23:31 
AnswerRe: Copying a file with progress Pin
Pete O'Hanlon2-Jun-09 23:51
mvePete O'Hanlon2-Jun-09 23:51 
GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 0:30
musefan3-Jun-09 0:30 
AnswerRe: Copying a file with progress Pin
Xmen Real 3-Jun-09 0:07
professional Xmen Real 3-Jun-09 0:07 
GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 0:32
musefan3-Jun-09 0:32 
GeneralRe: Copying a file with progress Pin
Xmen Real 3-Jun-09 2:36
professional Xmen Real 3-Jun-09 2:36 
GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 3:10
musefan3-Jun-09 3:10 
AnswerRe: Copying a file with progress Pin
harold aptroot3-Jun-09 0:27
harold aptroot3-Jun-09 0:27 
GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 0:42
musefan3-Jun-09 0:42 
AnswerRe: Copying a file with progress [modified] Pin
Alan N3-Jun-09 0:52
Alan N3-Jun-09 0:52 
GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 0:55
musefan3-Jun-09 0:55 
AnswerRe: Copying a file with progress [modified] Pin
harold aptroot3-Jun-09 0:55
harold aptroot3-Jun-09 0:55 
Shouldn't that be: (untested and I give no guarantee that I'm even making sense)
StreamReader sr = new StreamReader("inputfile.docx");
StreamWriter sw = new StreamWriter("outputfile.docx", false);

FileInfo fi = new FileInfo("inputfile.docx");
long total = fi.Length;

byte[] buffer = new byte[10000];
long byteCount = 0;

while(true)
{
  int bytesRead = sr.BaseStream.Read(buffer, 0, buffer.Length);//using .Length should ensure correct size
  byteCount += bytesRead;

  if(bytesRead == 0)//if end of file then break the loop
    break;

  //update progress
  sw.BaseStream.Write(buffer, 0, bytesRead); //otherwise you would write a piece of unused buffer space
}

sr.Close();
sw.Close();

Last modified: 14mins after originally posted -- changed to answer



GeneralRe: Copying a file with progress Pin
musefan3-Jun-09 1:05
musefan3-Jun-09 1:05 

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.