Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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");
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading