try { using (StreamReader sr = new StreamReader(Server.MapPath("template.html"))) { string line; while ((line = sr.ReadLine()) != null) { template.Append(line); } sr.Close(); } } catch (Exception ex) { Response.Write(ex.Message); Response.Write("<script>alert('读取文件错误')</script>"); }