<%@ Page %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e)
{
ReadReversed();
}
private void ReadReversed()
{
StreamReader sr = null;
string text;
string[] lines = {null};
try
{
sr = File.OpenText(Server.MapPath("textFile.txt"));
text = sr.ReadToEnd();
lines = text.Split('\n');
sr.Close();
for (int i=lines.Length-1;0<=i;i--)
{
HttpContext.Current.Response.Write(lines[i].ToString());
HttpContext.Current.Response.Write("<br />");
}
}
catch (Exception exc)
{
HttpContext.Current.Response.Write(exc.Message);
}
finally
{
if (sr != null)
sr.Close();
}
}
</script>
|