Click here to Skip to main content
15,922,696 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error management Pin
Simon P Stevens2-Jul-08 9:32
Simon P Stevens2-Jul-08 9:32 
GeneralRe: Error management Pin
Scalee2-Jul-08 9:36
Scalee2-Jul-08 9:36 
GeneralRe: Error management Pin
Simon P Stevens2-Jul-08 21:28
Simon P Stevens2-Jul-08 21:28 
Questionproblem retriving data form Oracle Pin
mateusz.matyaszek2-Jul-08 1:55
mateusz.matyaszek2-Jul-08 1:55 
QuestionFile copying, byte by byte, w/progress bar Pin
ajtunbridge2-Jul-08 1:42
ajtunbridge2-Jul-08 1:42 
AnswerRe: File copying, byte by byte, w/progress bar Pin
Scalee2-Jul-08 2:01
Scalee2-Jul-08 2:01 
GeneralRe: File copying, byte by byte, w/progress bar [modified] Pin
ajtunbridge2-Jul-08 2:17
ajtunbridge2-Jul-08 2:17 
AnswerRe: File copying, byte by byte, w/progress bar Pin
Anthony Mushrow2-Jul-08 2:41
professionalAnthony Mushrow2-Jul-08 2:41 
First off, ignore the ReadAllBytes suggestion, if your files are 40MB and you do have a few of them then its going to suck up alot of memory.

If you copy the file like this, you will be able to keep track of where you are:

const int BUFFERSIZE = 32768; //32KB
int bytesRead = 0;
long totalBytesRead = 0;
long fileSize = 0;
FileStream input = new FileStream("myfile", FileMode.Open);
FileStream output = new FileStream("mydestination", FileMode.Create);
byte[] buffer = new byte[BUFFERSIZE];
fileSize = input.Length;
.
while(totalBytesRead < fileSize)
{
  bytesRead = input.Read(buffer, 0, BUFFERSIZE);
  output.Write(buffer, 0, bytesRead);
  totalBytesRead += bytesRead;
}


Don't copy the file one byte at a time either, it will just go really slow. You can see your progress by checking totalBytesRead against fileSize.

Infact, you could set up an event and fire it in the while loop. Your main thread could then use this to update your progress bar etc.

My current favourite word is: I'm starting to run out of fav. words!
-SK Genius

Game Programming articles start -here[^]-

GeneralRe: File copying, byte by byte, w/progress bar Pin
ajtunbridge2-Jul-08 3:05
ajtunbridge2-Jul-08 3:05 
AnswerRe: File copying, byte by byte, w/progress bar Pin
Spacix One2-Jul-08 6:08
Spacix One2-Jul-08 6:08 
GeneralRe: File copying, byte by byte, w/progress bar Pin
Anthony Mushrow2-Jul-08 6:11
professionalAnthony Mushrow2-Jul-08 6:11 
GeneralRe: File copying, byte by byte, w/progress bar Pin
ajtunbridge3-Jul-08 0:45
ajtunbridge3-Jul-08 0:45 
QuestionMS Visual Studio compiling [modified] Pin
ALAQUNAIBI2-Jul-08 1:14
ALAQUNAIBI2-Jul-08 1:14 
AnswerRe: MS Visual Studio compiling Pin
leppie2-Jul-08 1:34
leppie2-Jul-08 1:34 
JokeRe: MS Visual Studio compiling Pin
User 66582-Jul-08 3:55
User 66582-Jul-08 3:55 
GeneralRe: MS Visual Studio compiling Pin
Pete O'Hanlon2-Jul-08 10:13
mvePete O'Hanlon2-Jul-08 10:13 
AnswerRe: MS Visual Studio compiling Pin
Simon P Stevens2-Jul-08 4:16
Simon P Stevens2-Jul-08 4:16 
QuestionSelection of Treeview node during page load Pin
shehezada2-Jul-08 1:03
shehezada2-Jul-08 1:03 
AnswerRe: Selection of Treeview node during page load Pin
ajtunbridge2-Jul-08 2:33
ajtunbridge2-Jul-08 2:33 
GeneralRe: Selection of Treeview node during page load Pin
shehezada2-Jul-08 22:19
shehezada2-Jul-08 22:19 
QuestionHow to prevent user to go back to desktop? Pin
bug_aonz2-Jul-08 0:58
bug_aonz2-Jul-08 0:58 
AnswerRe: How to prevent user to go back to desktop? Pin
subai2-Jul-08 1:07
subai2-Jul-08 1:07 
AnswerRe: How to prevent user to go back to desktop? Pin
Simon P Stevens2-Jul-08 1:09
Simon P Stevens2-Jul-08 1:09 
AnswerRe: How to prevent user to go back to desktop? Pin
blackjack21502-Jul-08 3:41
blackjack21502-Jul-08 3:41 
GeneralRe: How to prevent user to go back to desktop? Pin
Harvey Saayman2-Jul-08 4:33
Harvey Saayman2-Jul-08 4:33 

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.