Click here to Skip to main content
15,917,642 members
Home / Discussions / C#
   

C#

 
AnswerRe: Directory Stream Pin
Xmen Real 15-Apr-09 18:39
professional Xmen Real 15-Apr-09 18:39 
QuestionWatching for Removeable Drives Pin
Jammer15-Apr-09 12:20
Jammer15-Apr-09 12:20 
AnswerRe: Watching for Removeable Drives Pin
Luc Pattyn15-Apr-09 12:42
sitebuilderLuc Pattyn15-Apr-09 12:42 
AnswerRe: Watching for Removeable Drives Pin
Nilesh Hapse15-Apr-09 20:16
Nilesh Hapse15-Apr-09 20:16 
QuestionSocket Connection Shutdown and Close Pin
kikeman15-Apr-09 11:41
kikeman15-Apr-09 11:41 
AnswerRe: Socket Connection Shutdown and Close Pin
Colin Angus Mackay15-Apr-09 12:12
Colin Angus Mackay15-Apr-09 12:12 
GeneralRe: Socket Connection Shutdown and Close Pin
kikeman16-Apr-09 4:45
kikeman16-Apr-09 4:45 
GeneralRe: Socket Connection Shutdown and Close Pin
Colin Angus Mackay16-Apr-09 5:05
Colin Angus Mackay16-Apr-09 5:05 
GeneralRe: Socket Connection Shutdown and Close Pin
kikeman16-Apr-09 5:39
kikeman16-Apr-09 5:39 
GeneralRe: Socket Connection Shutdown and Close Pin
Colin Angus Mackay16-Apr-09 5:48
Colin Angus Mackay16-Apr-09 5:48 
AnswerRe: Socket Connection Shutdown and Close Pin
kikeman16-Apr-09 5:55
kikeman16-Apr-09 5:55 
QuestionTask Scheduler Pin
BlitzPackage15-Apr-09 11:40
BlitzPackage15-Apr-09 11:40 
AnswerRe: Task Scheduler Pin
Pete O'Hanlon15-Apr-09 11:45
mvePete O'Hanlon15-Apr-09 11:45 
GeneralRe: Task Scheduler Pin
BlitzPackage15-Apr-09 15:59
BlitzPackage15-Apr-09 15:59 
AnswerRe: Task Scheduler Pin
Rolando CC15-Apr-09 12:52
professionalRolando CC15-Apr-09 12:52 
GeneralRe: Task Scheduler Pin
BlitzPackage15-Apr-09 15:58
BlitzPackage15-Apr-09 15:58 
AnswerRe: Task Scheduler Pin
Giorgi Dalakishvili15-Apr-09 19:45
mentorGiorgi Dalakishvili15-Apr-09 19:45 
QuestionVS2008 Startup, Environment, Options Dialog Box missing Pin
Neville Franks15-Apr-09 10:51
Neville Franks15-Apr-09 10:51 
AnswerRe: VS2008 Startup, Environment, Options Dialog Box missing Pin
Neville Franks15-Apr-09 11:00
Neville Franks15-Apr-09 11:00 
JokeWhat are trees doing in your pants? Pin
Naruki15-Apr-09 15:18
Naruki15-Apr-09 15:18 
GeneralRe: What are trees doing in your pants? Pin
Neville Franks15-Apr-09 16:26
Neville Franks15-Apr-09 16:26 
JokeRe: What are trees doing in your pants? Pin
Naruki15-Apr-09 16:54
Naruki15-Apr-09 16:54 
GeneralRe: What are trees doing in your pants? Pin
Neville Franks15-Apr-09 18:00
Neville Franks15-Apr-09 18:00 
QuestionProgress while reading a file Pin
nike_arh15-Apr-09 10:38
nike_arh15-Apr-09 10:38 
Hi! I have to read a file and do some operations to it. The contents of the file are words - it is like a dictionary (over 10 000 words, later over 80 000). Each word must be read and compared to others. Which is the best way of accessing the data (and the fastest):
1) Read the whole file and add the lines to an ArrayList, after that the stream is disposed. Then do whatever I want to the lines.
OR
2) Open the stream and read each line and do whatever I want to it. During all the time the stream is opened!

Also I want to report progress.
1) With the the ArrayList:

int progress = 0;<br />
for (int i = 0; i < rawLines.Count; i++)<br />
{<br />
   line = rawLines[i] as string;<br />
   if ((i / rawLines.Count) * 100 > progress)<br />
   {<br />
      progress = (i / rawLines.Count) * 100; //the new progress value<br />
      Console.Title = progress.ToString() + "%";<br />
   }<br />
   //<br />
   //some stuff to the line<br />
   //<br />
}


2) With the stream:

int progress = 0;<br />
int rawProgress;<br />
while ((line = reader.ReadLine()) != null)<br />
{<br />
   rawProgress = (int)((reader.BaseStream.Position / reader.BaseStream.Length) * 100);<br />
   if (rawProgress > progress)<br />
   {<br />
      progress = rawProgress; //the new progress value<br />
      Console.Title = progress.ToString() + "%";<br />
   }<br />
   //<br />
   //some stuff to the line<br />
   //<br />
}


But! Both ways don't seem to work. With the stream, the value of reader.BaseStream.Position is always 1024. In the other case the value of i increases but the percentage in the console's title does not change?!

Still learning...

AnswerRe: Progress while reading a file Pin
amtadhani15-Apr-09 10:45
amtadhani15-Apr-09 10:45 

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.