Last post Sep 01, 2014 09:41 PM by May-song
Sep 01, 2014 04:10 AM|santosh0288|LINK
I am trying to download files from a site and was downloading from last 1 year but suddenly it stopped downloading the files instead it is downloading the page's HTML content rather than the files. below is the part of my source code which does the downloading
it is a windows application and using web browser i am trying to download files. CookieAwareWebClient is the class in which i have downloadfile method which does it. below mentioned source code demonstrates it.
_logObj.Debug("Entered DO.Downloader.DOFileDownload.downloadfile(string _filelink, string fileName3).");
if (string.IsNullOrEmpty(pFilelink) || string.IsNullOrEmpty(pFileName3))
throw new System.Exception("pFilelink or pFileName3 is not initialized or empty, Please check !");
string FilePath = _downloadDestination + pFileName3;
CookieAwareWebClient client = new CookieAwareWebClient();
client.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.CookieContainer = cookies;
client.Headers.Add("User-Agent", "my App");
// client.Headers.Add("Accept", "*/*");
HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
client.CachePolicy = policy;
client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted);
// string content=client.DownloadString(pFilelink);
client.DownloadFile(new Uri(pFilelink), FilePath);
Can any one help me to solve this issue ?
Santosh Kumar Dash
Sep 01, 2014 09:41 PM|May-song|LINK
Hi Santosh Kumar Dash,
Not able to Download files using CookieAwareWebClient class through web browser
On this issue, I also learn a little, so I suggest you could review the following articles, hope it can help you.
If you have any other questions, please feel free to post in this forum.