下面是按钮调用的下载方法。求指点。
protected bool WriteOutFile(string filePath)
{
System.IO.FileInfo pdfFile = new System.IO.FileInfo(filePath);
//写出文件
System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("gb2312");
HttpResponse response = HttpContext.Current.Response;
response.HeaderEncoding = encoding;
response.Charset = encoding.HeaderName;
response.Clear();
response.ContentEncoding = encoding;
response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(pdfFile.Name));
response.AddHeader("Content-Length", pdfFile.Length.ToString());
response.ContentType = "text/plain";// "application/pdf";
response.WriteFile(pdfFile.FullName);
HttpContext.Current.ApplicationInstance.CompleteRequest();
return true;
}