Home > Net >  Reading the contents of a file into a richtextbox. But recognising new lines
Reading the contents of a file into a richtextbox. But recognising new lines

Time:12-24

This is the code I have so far. However obviously its putting everything into a list and inserting that into a text box but the problem I'm having is I'm unsure how to get it to recognise new lines and make a new list. I roughly know what I need to do but I'm having a hard time imagining it.

    private void Form3_Load(object sender, EventArgs e)
    {
        List<string> lines = File.ReadLines("Help.md").ToList();

        foreach (string current in lines)
        {
            HelpTextBox.Text  = current;
        }
    }

What should I do, I think I need some sort of selection to check if a new line has started in my file?

Thank you in advance!

CodePudding user response:

Why not load entire Help.md file and set Text in one go?

private void Form3_Load(object sender, EventArgs e)
{
    HelpTextBox.Text  = File.ReadAllText("Help.md");
}
  • Related