friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2008-11-11 17:21:28

creamownedz
 active server protocol
creamownedz's display avatar
» FriendsterTalker
PsychoCoder
Class-S
Location: Ftalk & MCTF
Registered: 2008-03-22
Posts: 115
Last visit: Yesterday
Reputation: 7

Retrieve data from a URL using WebClient class [c#]

Instructions: You will need a reference to the following Namespaces

System.Net
System.Text


Code:

/// <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);
}

...Giving of reputation are highly appreciating for me...
Computers don't make errors what they do they do on purpose
...computer is my expertise...
....an addicted coder....
....don't ripp all my tutorials....

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
Copyright © 2002–2009 PunBB

[ 8 queries - 0.029 second ]

Pay Per Click Ads by pay per click advertising by Kontera

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)