
Instructions: You will need a reference to the following Namespaces
System.Net
System.Text
/// <summary>
/// method for retrieving information from a specified URL
/// using the new WebClient Class in .Net 2.0
/// </summary>
/// <param name="url">url to retrieve data from</param>
/// <returns></returns>
public string LoadeSiteContent(string url)
{
//create a new WebClient object
WebClient client = new WebClient();
//create a byte array for holding the returned data
byte[] html = client.DownloadData(url);
//use the UTF8Encoding object to convert the byte
//array into a string
UTF8Encoding utf = new UTF8Encoding();
//return the converted string
return utf.GetString(html);
}-Offline- |