i am Working on a Project on tech asp.net C#
I Have a Notepad file almost 250 MB i want to Write its Text on TextBox
I used this Code but it taking too much time at last Throwing error
OutOfMemoryException
any one can suggest me what is the Easiest way.
Here is the Code Below.
StringBuilder fileText = new StringBuilder();
using (FileStream fs = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (BufferedStream bs = new BufferedStream(fs))
using (StreamReader sr = new StreamReader(bs))
{
string line = "";
txtReader.Text = "";
while ((line = sr.ReadLine()) != null)
{
//fileText.AppendLine(line);
txtReader.Text += line.ToString();
}
}
txtReader.Text = fileText.ToString();

Rahul Singh179 reputationPosted Jan 29, 2018, 8:46 PM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 29, 2018, 10:35 PM EST
Manav PandyaRank #166 · 14.3K reputationPosted Jan 30, 2018, 12:29 AM EST
Rahul Singh179 reputationPosted Jan 29, 2018, 10:54 PM EST
Manav PandyaRank #166 · 14.3K reputationPosted Jan 29, 2018, 9:03 PM EST
Manav PandyaRank #166 · 14.3K reputationPosted Jan 29, 2018, 7:57 PM EST
Sagar Pandurang KapRank #606 · 4K reputationPosted Jan 29, 2018, 8:03 PM EST