Click here to Skip to main content
15,893,381 members
Home / Discussions / C#
   

C#

 
GeneralSmart Device Application with SQL Server Ce Pin
mathon6-Sep-04 0:28
mathon6-Sep-04 0:28 
GeneralDataGrid hangs when using threads Pin
tobiaseriksson6-Sep-04 0:00
tobiaseriksson6-Sep-04 0:00 
GeneralRe: DataGrid hangs when using threads Pin
Roger Alsing6-Sep-04 3:47
Roger Alsing6-Sep-04 3:47 
GeneralRe: DataGrid hangs when using threads Pin
tobiaseriksson6-Sep-04 4:55
tobiaseriksson6-Sep-04 4:55 
GeneralChild Window with Focus *at same time as parent* Pin
Geekkit5-Sep-04 23:35
Geekkit5-Sep-04 23:35 
GeneralI have a problem,Creating xslt instructions Pin
teo_x5-Sep-04 22:37
teo_x5-Sep-04 22:37 
GeneralGet server time from remote server Pin
cbmdk5-Sep-04 22:19
cbmdk5-Sep-04 22:19 
GeneralProblems with huge files Pin
clatten5-Sep-04 22:15
clatten5-Sep-04 22:15 
I am working on an app that should open a logfile and then it should be possible to:

1. output the whole file as it is
2. reverse the output
3. filter the output

I am outputting to a richtextbox since I also want to highlight specific lines.

I have tried both using ArrayList and StringBuilder. The latter seems better but then it is not so easy to reverse. To add all text to the RichTextBox I use RTB.Text. I have also thought of outputting all to a temp file and use RTB.LoadFile instead.

The problem is that the logfiles can be quite huge, >5MB in extreme cases. This causes it to be very slow and I also encounter out-of-index problems in certain situations that I have not been able to pin down in the debugger.

Could anyone advice me on the best way to get a stable and not to slow solution (since I have to work through the whole file line by line to filter it will never be quick)?

Code extract:

try
{
StreamReader sr = File.OpenText(fileName);
string input = null;
//ArrayList myList = new ArrayList();
StringBuilder sb = new StringBuilder();

while ((input = sr.ReadLine()) != null)
{
if ( Filter or not )
{
Filtering of each line.
If condition met then
sb.Append(input);
//myList.Add(input);
}
}
else {
sb.Append(input);
//myList.Add(input);
//myList.TrimToSize();
}
}
sr.Close();
//myList.TrimToSize();
if ( checkBox4.Checked ) { //myList.Reverse(); }
richTextBox1.Clear();

/*
for (int i=0;i<myList.Count;i++)
{
sb.Append(myList[i].ToString() + "\n");
}
*/
richTextBox1.Text = sb.ToString();
}
catch (Exception e)
{ MessageBox.Show(e.ToString()); }
}
GeneralRe: Problems with huge files Pin
Sebastian Schneider6-Sep-04 3:11
Sebastian Schneider6-Sep-04 3:11 
GeneralRe: Problems with huge files Pin
clatten6-Sep-04 10:07
clatten6-Sep-04 10:07 
GeneralEnabledChanged event of inputPanel of .NET CF error Pin
ting6685-Sep-04 21:25
ting6685-Sep-04 21:25 
GeneralDirectly deriving from MulticastDelegate Pin
Paul Selormey5-Sep-04 21:08
Paul Selormey5-Sep-04 21:08 
GeneralRe: Directly deriving from MulticastDelegate Pin
sreejith ss nair5-Sep-04 22:57
sreejith ss nair5-Sep-04 22:57 
GeneralRe: Directly deriving from MulticastDelegate Pin
Paul Selormey5-Sep-04 23:06
Paul Selormey5-Sep-04 23:06 
Generala question of Directx9 Pin
sssa20005-Sep-04 20:15
sssa20005-Sep-04 20:15 
GeneralRe: a question of Directx9 Pin
EssOEss6-Sep-04 5:01
EssOEss6-Sep-04 5:01 
GeneralC# equivalent of the /fx C++ compiler option Pin
Paul Selormey5-Sep-04 20:10
Paul Selormey5-Sep-04 20:10 
GeneralRe: C# equivalent of the /fx C++ compiler option Pin
leppie5-Sep-04 23:08
leppie5-Sep-04 23:08 
GeneralRe: C# equivalent of the /fx C++ compiler option Pin
Paul Selormey6-Sep-04 0:34
Paul Selormey6-Sep-04 0:34 
GeneralRe: C# equivalent of the /fx C++ compiler option Pin
EssOEss6-Sep-04 5:03
EssOEss6-Sep-04 5:03 
GeneralRe: C# equivalent of the /fx C++ compiler option Pin
Paul Selormey6-Sep-04 12:25
Paul Selormey6-Sep-04 12:25 
General&quot;Overloading&quot; delegate Pin
Paul Selormey5-Sep-04 19:47
Paul Selormey5-Sep-04 19:47 
GeneralRe: &quot;Overloading&quot; delegate Pin
leppie5-Sep-04 22:43
leppie5-Sep-04 22:43 
GeneralRe: &quot;Overloading&quot; delegate Pin
Paul Selormey5-Sep-04 22:55
Paul Selormey5-Sep-04 22:55 
GeneralRe: &quot;Overloading&quot; delegate Pin
leppie5-Sep-04 23:24
leppie5-Sep-04 23:24 

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.