Reg: Loading text file(size 100 MB) in Richtextbox

May 8 2012 6:56 AM
Hi,
        I am trying to load 100 MB of Text file in rich text box, but the application gets hang  or some times it gives out of memory exception. 
I tried below

Case1: it is running for long time
fs = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                sr = new StreamReader(fs);
                //rtxtFile.AppendText( sr.ReadToEnd());
                while (!sr.EndOfStream)
                {
                    rtxtFile.AppendText(sr.ReadLine() + System.Environment.NewLine);
                }

Case2:  out of memory exception
fs = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                sr = new StreamReader(fs);
                rtxtFile.AppendText( sr.ReadToEnd());
        
anybody give the solution for the above problem;

with reagrds,
Vishnuvarthan.V


Answers (4)