Send text file to client : Write « Response « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » Response » Write 




<%@ 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>














6.4.Write
6.4.1.Use Response.Write to output message based on HTML tags (VB.net)
6.4.2.Calculation in Response.Write (VB)
6.4.3.Calculation in Response.Write (C#)
6.4.4.Output integer and string in Response.Write
6.4.5.Output HTML tags in Response.Write, change the tag properties dynamicallys (VB.net)
6.4.6.Create Client Side MessageBox
6.4.7.Send text file to client
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.