Space identification in TXT Asp.net file

Asked

Viewed 89 times

0

good evening, I am not able to display line break coming from my TXT file, I have a TXT file with 5 sentences, but when I put to display the default page by a literal loads the txt file but the sentences are displayed without line break all together, I’d like that help, the code :

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


    foreach (string line in linhas)
    {

        LiteralTXT.Text +=  line;


    }

1 answer

2


It’s simple, just add the line break characters, "\r\n", before each item of the foreach, 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}";
}
  • Wouldn’t it be better to use <br> ? Since it’s web ?

  • yes I know the <br> it identifies where has the line break, but my coordinator wants you to identify the spacing, I tested your solution continued together.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.