如何从受保护的以下链接http://epaper.manoramaonline.com/MMDaily/Malappuram/2014/05/30/F/MMDaily_Malappuram_2014_05_30_F_FP_001/1228_274_1940_1862.jpg
当我下载此jpeg文件时,显示以下错误"远程服务器返回错误(403)禁止"。请帮我找一个解决方案。
使用了以下代码..
My.Computer.Network.DownloadFile("http://epaper.manoramaonline.com/MMDaily/Malappuram/2014/05/30/F/MMDaily_Malappuram_2014_05_30_F_FP_001/1228_274_1940_1862.jpg", "D:/ynews.jpg")
答案 0 :(得分:0)
您可能需要指定网络凭据以绕过授权和身份验证。我可以给你一个C#代码相同的例子。你用VB.Net检查一下并尝试解决。
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient.Credentials = new NetworkCredential("user", "pass");
webClient.DownloadFileAsync(new Uri("http://example.com/example.jpg"), @"c:\myfile.txt");