.net讀取輸出項目中html文件

using System.Net;
using System.Text;
using System.IO;

 

   protected void Page_Load(object sender, EventArgs e)
        {
            Encoding code = Encoding.GetEncoding("gb2312");
            // 讀取模板文件
            string temp = HttpContext.Current.Server.MapPath("/CSInterface/html/games.htm");
            StreamReader sr = null;
            string str = string.Empty;
            try
            {
                sr = new StreamReader(temp, code);
                str = sr.ReadToEnd(); // 讀取文件
            }
            catch (Exception exp)
            {
                str = "error";
                sr.Close();
            }
            Response.Write(str);
        }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章