I have an application where the user can write articles and they will be displayed on a web page. Instead of storing all the text in the database I want to write it to a text file and store it that way. The problem is, I can't seem to get the file to hold formatting ie line breaks. If the user types
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget ligula eget quam consectetur ornare. Integer sed sapien risus, ac tincidunt lectus. Quisque ultrices mi tortor. Fusce luctus magna non dolor facilisis imperdiet. Praesent tempus gravida dolor, sit amet viverra ligula vehicula sit amet.
Donec congue sodales orci, in sodales nunc fermentum quis. Proin feugiat feugiat ultrices. Mauris iaculis libero non nibh sagittis fermentum. Etiam odio sapien,
pulvinar sed viverra nec, euismod eu massa. Sed pulvinar diam a velit rhoncus non iaculis mi facilisis.
and then saves, it is saved as
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget ligula eget quam consectetur ornare. Integer sed sapien risus, ac tincidunt lectus. Quisque ultrices mi tortor. Fusce luctus magna non dolor facilisis imperdiet. Praesent tempus gravida dolor, sit amet viverra ligula vehicula sit amet. Donec congue sodales orci, in sodales nunc fermentum quis. Proin feugiat feugiat ultrices. Mauris iaculis libero non nibh sagittis fermentum.Etiam odio sapien, pulvinar sed viverra nec, euismod eu massa. Sed pulvinar diam a velit rhoncus non iaculis mi facilisis.
Is there any way to maintain formatting?
Current code is
var fileContents = System.IO.File.ReadAllText(Server.MapPath(@"~/Articles/" + articlePost.atclFile + ".txt"));
articleTextbox.Text = fileContents.Replace(System.Environment.NewLine, "<br/>");
articleTextbox
? A textbox? – System Down