string GetURLContent(string url, string EncodingType)
{
string PetiResp = "";
Stream mystream;
//"http://go.microsoft.com/fwlink/?LinkId=25817"
//"utf-8"
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
req.AllowAutoRedirect = true;
System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)req.GetResponse();
if (resp.StatusCode == System.Net.HttpStatusCode.OK)
{
mystream = resp.GetResponseStream();
System.Text.Encoding encode = System.Text.Encoding.GetEncoding(EncodingType);
StreamReader readStream = new StreamReader(mystream, encode);
char[] cCont = new char[500];
int count = readStream.Read(cCont, 0, 256);
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(cCont, 0, count);
PetiResp += str;
count = readStream.Read(cCont, 0, 256);
}
resp.Close();
return PetiResp;
}
resp.Close();
return null;
}