如何在单击按钮时下载pdf文件? C# [英] how to download a pdf file on a button click? C#
本文介绍了如何在单击按钮时下载pdf文件? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在单击按钮时下载pdf文件? c#
how to download a pdf file on a button click? c#
推荐答案
尝试一下,
try this,
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=pdffile.pdf");
Response.TransmitFile(Server.MapPath("~/F:\\pdffile.pdf"));
Response.End();
您只需要执行一个命令即可,该命令是指向文件的链接:
var procStartInfo =新的System.Diagnostics.ProcessStartInfo
("http://img.listal.com/image/8863/600full-nicole-kidman.jpg");
System.Diagnostics.Process proc =新的System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
有一些产品可以添加命令行保存功能:Windows的Wget http://gnuwin32.sourceforge. net/packages/wget.htm [^ ]
You should only have to execute a command that is the link to the file:
var procStartInfo = new System.Diagnostics.ProcessStartInfo
("http://img.listal.com/image/8863/600full-nicole-kidman.jpg");
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
There are a few products that will add the ability to do a command line save: Wget for Windowshttp://gnuwin32.sourceforge.net/packages/wget.htm[^]
最简单的方法是使用
The easiest way is to use
Response.Redirect(urlofpdffile);
这篇关于如何在单击按钮时下载pdf文件? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文