/ / webclient.downloadfileページを完全に保存しない - C#、.net、webclient、webclient-download

webclient.downloadfileはページを完全に保存しません - c#、.net、webclient、webclient-download

次のコードを使用してC#アプリケーションにWebページを保存しますが、ページは完全に保存されません。

WebClient webClient = new WebClient();
webClient.DownloadFile("http://jahanesanat.ir/currency.html", @"d://test/mytest66.html");

ページの一部がローカルファイルに保存されない 何がうまくいかないのですか?

回答:

回答№1は0

たぶんd://テスト/アクセスが拒否されている

MSDNのこのサンプルを使用する

string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File "{0}" from "{1}" .......nn", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File "{0}" from "{1}"", fileName, myStringWebResource);
Console.WriteLine("nDownloaded file saved in the following file system folder:nt" + Application.StartupPath)