Something like
List<string> lines = File.ReadLines ("E:\\vikas\\abc.txt").ToList();
foreach (string current in lines)
{
richTextBox1.Text += current;
}
سؤال
I have a textfile which contains texts.Now as per my requirement i have to read this textfile line by line into the richtextbox.At present i am reading all lines of the text file at once into richtextbox.Here is my code ..
richTextBox1.Text = File.ReadAllText("E:\\vikas\\abc.txt");
But i want to display the texts of the textfile into richtextbox line by line.
المحلول
Something like
List<string> lines = File.ReadLines ("E:\\vikas\\abc.txt").ToList();
foreach (string current in lines)
{
richTextBox1.Text += current;
}
نصائح أخرى
not checked, but you just do something like this. you do not want to read it straight into a textbox, because that is slow!!!
using(StreamReader sr = new StreamReader(filename)
{
StringBuilder sb = new StringBuilder();
While(sr.Peek() >-1)
{
sb.Append( sr.ReadLine() );
}
The_Textbox.Text = sb.ToString();
}