Identification of TXT asp.net file space

0

Good night, I am not able to display line break that comes from my TXT file, I have a TXT file with 5 phrases, but when I put it to display it in the default page, a literal loads the txt file, but the sentences are displayed without breaking line, I would like this help, the code:

string[] linhas = System.IO.File.ReadAllLines(@"C:\Users\aless\Desktop\txt\frases.txt");


    foreach (string line in linhas)
    {

        LiteralTXT.Text +=  line;


    }
    
asked by anonymous 19.10.2018 / 02:19

1 answer

2

It's simple, you simply add the line break characters, "\r\n" , before each item of foreach , it follows code:

string[] linhas = System.IO.File.ReadAllLines(@"C:\Users\aless\Desktop\txt\frases.txt");

foreach (string line in linhas)
{
    LiteralTXT.Text += $"\r\n{line}";
}
    
19.10.2018 / 06:21