可以试试这个
using (var client = new WebClient())
{
client.DownloadFile("http://www.mbank.pl/bin/sfi/sfi_do_csv.php?sh=0,3,4,5,6,7,8,9,10,11&date=2013-04-05&sorted=StopaZw1r_down&fund_type=&collection=&show=all", @"D:\Downloads\1.zip");
}
或者如果有任何例外,试试这个
public void DownloadFile(string _URL, string _SaveAs)
{
try
{
System.Net.WebClient _WebClient = new System.Net.WebClient();
// Downloads the resource with the specified URI to a local file.
_WebClient.DownloadFile(_URL, _SaveAs);
}
catch (Exception _Exception)
{
// Error
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString());
}
}
或者试试这个会工作
public class WebDownload : WebClient
{
private int _timeout;
/// <summary>
/// Time in milliseconds
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public WebDownload()
{
this._timeout = 60000;
}
public WebDownload(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}