Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + pt.TemplateName + pt.FileExtension);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-word";
Response.WriteFile(System.Configuration.ConfigurationSettings.AppSettings["TemplatePhysicalPath"].ToString() + pt.Path); Response.End();
//现在是将文件转化成字节流输出:
FileStream f = new FileStream(System.Configuration.ConfigurationSettings.AppSettings["TemplatePhysicalPath"].ToString() + pt.Path, FileMode.Open);
byte[] buffer = new byte[f.Length];
f.Read(buffer, 0, buffer.Length);
f.Close();
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + pt.TemplateName + pt.FileExtension);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-word";
//Response.WriteFile(System.Configuration.ConfigurationSettings.AppSettings["TemplatePhysicalPath"].ToString() + pt.Path);
Response.BinaryWrite(buffer);
Response.GetHashCode();
Response.End();