标签:
public static void Priview(System.Web.UI.Page p, string inFilePath)
{
p.Response.ContentType = "Application/pdf";
string fileName = inFilePath.Substring(inFilePath.LastIndexOf(‘\\‘) + 1);
p.Response.AddHeader("content-disposition", "filename=" + fileName);
p.Response.WriteFile(inFilePath);
p.Response.End();
}
public static void Preview(System.Web.UI.Page p, string inFilePath)
{
string fileName = inFilePath.Substring(inFilePath.LastIndexOf(‘\\‘) + 1);
p.Response.ContentType = "text/plain";
p.Response.ContentEncoding = System.Text.Encoding.UTF8; //保持和文件的编码格式一致
p.Response.AddHeader("content-disposition", "filename=" + fileName);
p.Response.WriteFile(inFilePath);
p.Response.End();
}
Asp.net实现直接在浏览器预览Word、Excel、PDF、Txt文件(附源码)
标签:
原文地址:http://www.cnblogs.com/ydfq-home/p/5017250.html