ASP.NET
C#
Read and display a text file
Inline Scripting
Uses StreamReader Object. Replaces \r and \n with <br>
<script runat="server"> public string ReadTextFile() { // The @ sign is for the path inclosed by quotes. verbatim string literal string FullPath = @"\\wdmycloudex2\webpage\TimJenkinsWeb\Testing\"; // When using inline scipt you have to give the complete object path // Like System.IO.File.OpenTest instead of just File.OpenText System.IO.StreamReader sr = System.IO.File.OpenText(FullPath + "03a-SampleTextFile.txt"); string strContents = sr.ReadToEnd(); // Replaces all return and new line with html line breaks strContents = strContents.Replace("\r\n","<br>"); return strContents; } </script> <% =ReadTextFile() %>