Click here to Skip to main content
15,897,291 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Progress while reading a file Pin
nike_arh15-Apr-09 10:53
nike_arh15-Apr-09 10:53 
AnswerRe: Progress while reading a file Pin
Luc Pattyn15-Apr-09 10:55
sitebuilderLuc Pattyn15-Apr-09 10:55 
GeneralRe: Progress while reading a file Pin
nike_arh15-Apr-09 11:14
nike_arh15-Apr-09 11:14 
GeneralRe: Progress while reading a file Pin
Luc Pattyn15-Apr-09 11:19
sitebuilderLuc Pattyn15-Apr-09 11:19 
QuestionList view question Pin
al3xutzu0015-Apr-09 10:03
al3xutzu0015-Apr-09 10:03 
AnswerRe: List view question Pin
Luc 64801115-Apr-09 10:07
Luc 64801115-Apr-09 10:07 
GeneralRe: List view question Pin
DaveyM6915-Apr-09 10:08
professionalDaveyM6915-Apr-09 10:08 
AnswerRe: List view question Pin
DaveyM6915-Apr-09 10:07
professionalDaveyM6915-Apr-09 10:07 
AnswerRe: List view question Pin
al3xutzu0015-Apr-09 10:10
al3xutzu0015-Apr-09 10:10 
Questionweb develpoment Pin
elazor15-Apr-09 9:46
elazor15-Apr-09 9:46 
AnswerRe: web develpoment Pin
buachaill cliste15-Apr-09 10:02
buachaill cliste15-Apr-09 10:02 
GeneralRe: web develpoment Pin
elazor15-Apr-09 19:14
elazor15-Apr-09 19:14 
QuestionSpreadsheet COM in window form application Pin
Binqing15-Apr-09 8:47
Binqing15-Apr-09 8:47 
AnswerRe: Spreadsheet COM in window form application Pin
buachaill cliste15-Apr-09 10:40
buachaill cliste15-Apr-09 10:40 
GeneralRe: Spreadsheet COM in window form application Pin
Binqing15-Apr-09 11:01
Binqing15-Apr-09 11:01 
QuestionCreating a DataTable with the data from an SQL SELECT statement Pin
stonebergftw15-Apr-09 8:31
stonebergftw15-Apr-09 8:31 

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.