Session["FileFullName"]=this.Server.MapPath("")+@"\LAWS\"+tmpNode.Text+@"\"+tmpSubNode.Text.Trim()+".txt";StreamReader sr= new StreamReader((filename),Encoding.Default);
string ReadFileContent=sr.ReadToEnd().ToString();

ReadFileContent = ReadFileContent.Replace(" "," ");
ReadFileContent = ReadFileContent.Replace("\t","&nbsp;&nbsp;&nbsp;&nbsp;"); ReadFileContent = ReadFileContent.Replace("\n","<br>");

ReadFileContent = ReadFileContent.Replace("<","&lt;") ;
ReadFileContent = ReadFileContent.Replace(">","&gt;") ;
ReadFileContent = ReadFileContent.Replace("\"","&quot;");

this.Page.Response.Write(ReadFileContent);
sr.Close();

解决方案 »

  1.   

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '在此处放置初始化页的用户代码
            Dim Content As String
            Dim objFile, fsoA As Object
            fsoA = Server.CreateObject("Scripting.FileSystemObject")
            objFile = fsoA.OpenTextFile(Server.MapPath("xiao.txt"), 1, False)
            If objFile.AtEndOfStream = False Then
                Content = objFile.ReadAll
                Content = Replace(Content, Chr(13), "<Br>")
                Response.Write(Content)
            End If
        End Sub
      

  2.   

    超链接:http://202.xxx/file/temp.txt下载到客户端(打开或保存):string scFileName="temp.txt";
    string filePath=Server.MapPath(.)+"/file/"+scFileName;Response.AppendHeader("Content-Disposition","attachment; filename="+HttpUtility.UrlEncode(scFileName,System.Text.Encoding.UTF8));
    Response.WriteFile(filePath);
      

  3.   

    超链接足已,不过也可以像写word等文件一样用response对像向客户端写数据>
      

  4.   

    超连也可打开,或你用file与stream也可以打开读写
      

  5.   

    你可以用file打开文件,然后把文件中读取得内容赋给文本框
    filename = Server.MapPath("/test.txt");
    mystreamreader = File.OpenText(filename);
    strText = mystreamreader.ReadToEnd();
    mystreamreader.Close();
    TextBox1.Text = strText;