如何使webClient.DownloadFile工作?

时间:2017-07-25 04:21:09

标签: download webclient-download

单击链接按钮时,这是我的代码:

protected void btnDownload_OnClick(object sender, EventArgs e)
{
        string url = "https://ppespcollab.amat.com/sites/IMDb/Shared Documents/LatestTest_IMDb_LPDetails_Template.xlsx";

        string file_name = Server.MapPath(".") + "\\Sample.xlsx"; ;
        WebClient webClient = new WebClient();
        webClient.UseDefaultCredentials = true;

        webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

        webClient.DownloadFile(url, @file_name);
        webClient.Dispose();
}

没有显示错误。但它不下载。我很无能为力。试过不同的方式。什么都行不通。

0 个答案:

没有答案