无法使用webclient下载文件

时间:2018-04-03 12:02:24

标签: c# webclient-download

我尝试下载此类链接中提供的文件..

https://xxxxx.xxx/ff?fid=123.456

如果我使用webbrowser下载它,它可以工作但不是我使用此代码时..

            try
        {
            using (var wc = new WebClient())
            {
                wc.DownloadFile(fileUri, AppDomain.CurrentDomain.BaseDirectory + "\\donload\\test.xlsx");

            }
        }
        catch (Exception ex)
        {
            //log.Error..
        }

当我这样做时,我得到一个“远程服务器返回错误:(404)Not Found。”如何下载文件,并使用从网址返回的名称保存文件?

0 个答案:

没有答案