I'm having difficulties downloading a product image from tkmaxx.com
http://www.tkmaxx.com/content/ebiz/tkmaxx/invt/B./1./A./21866003/21866003_medium.jpg
try
{
string filePath = "D:\\temp\\test.jpg";
WebClient webClient = new WebClient();
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
webClient.DownloadFile("http://www.tkmaxx.com/content/ebiz/tkmaxx/invt/B./1./A./21866003/21866003_medium.jpg", filePath);
}
catch (Exception ex)
{
}
I keep receiving a 404 error message. I have taken a look at a lot of forum threads, however I cannot seem to resolve this issue.
The only thing that i can think of is that TXMAXX.com have some server settings that does not allow image download?
Try this..
private void button1_Click(object sender, EventArgs e)
{
string url = "http://framework.zend.com/releases/ZendFramework-1.11.11/ZendFramework-1.11.11.zip";
WebClient downloader = new WebClient();
downloader.DownloadFileCompleted += new AsyncCompletedEventHandler(downloader_DownloadFileCompleted);
downloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloader_DownloadProgressChanged);
downloader.DownloadFileAsync(new Uri(url), "C:\\temp.zip");
}
void downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
label1.Text = e.BytesReceived + " " + e.ProgressPercentage;
}
void downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
MessageBox.Show(e.Error.Message);
else
MessageBox.Show("Completed!!!");
}
Ref: Downloaded file using webclient.DownloadFileAsync has 0KB
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.