using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
{
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });
// If credentials is required use this below line
client.Credentials = new System.Net.NetworkCredential("UserId", "Password", "DomainName");
// you can get the file content without saving it:
strHtmlCode = client.DownloadString(htmlDisplyFormUrl);
FileStream fStream = new System.IO.FileStream(@"D:\HtmlFolder\Sample.Html", System.IO.FileMode.Create);
byte[] b = System.Text.Encoding.UTF8.GetBytes(strHtmlCode);
fStream.Write(b, 0, b.Length);
fStream.Close();
//...
}
No comments:
Post a Comment