here is my code i used web client and pass my link to load file but file created in
folder contain htmlscript tag instead file content whats the wrong.see attach file
foreach (HtmlElement link in row.GetElementsByTagName("A"))
{
bool isFound = false;
string url = "";
isFound = true;
mshtml.HTMLAnchorElement anchor = link.DomElement as HTMLAnchorElement;
if (anchor != null)
{
url = anchor.href;
}
if (isFound && url != "")
{
WebClient client = new WebClient();
client.UseDefaultCredentials = true;
var fileName = @"C:\DownLoads\070813.GACT";
client.DownloadFile(url, fileName);
}
}
Loading

Mai Hu NaPosted Jul 11, 2013, 3:20 AM
You are not logged on. Please logon first.
instead of actual file content
Iftikar HussainPosted Jul 11, 2013, 3:06 AM
if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath)
oreach (HtmlElement link in row.GetElementsByTagName("A"))
{
bool isFound = false;
string url = "";
isFound = true;
mshtml.HTMLAnchorElement anchor = link.DomElement as HTMLAnchorElement;
if (anchor != null)
{
url = anchor.href;
}
if (isFound && url != "")
{
WebClient client = new WebClient();
client.UseDefaultCredentials = true;
var fileName = @"C:\DownLoads\070813.GACT";
client.DownloadFile(url, fileName);
}
}
}
Regards,
Iftikar
Mai Hu NaPosted Jul 11, 2013, 3:03 AM
Iftikar HussainPosted Jul 11, 2013, 2:41 AM
Before executing the code check weather your document is downloaded properly in your web browser control or not. You can do like this inside webBrowser1_DocumentCompleted
Regards,
Iftikar