Uri u
=
new
Uri(
"
http://192.168.1.68/xxxx/hitcout.xml
"
);
System.Net.HttpWebRequest myrequest
=
(System.Net.HttpWebRequest)System.Net.WebRequest.Create(u);
//
创建http请求
myrequest.Timeout
=
5000
;
//
设置超时时间
myrequest.Headers.Set(
"
Pragma
"
,
"
no-cache
"
);
//
设置头
System.Net.HttpWebResponse myresponse
=
(System.Net.HttpWebResponse)myrequest.GetResponse();
System.IO.Stream mystream
=
myresponse.GetResponseStream();
//
获取输出流
System.Text.Encoding myencode
=
System.Text.Encoding.GetEncoding(
"
gb2312
"
);
//
编码
StreamReader objReader
=
new
StreamReader(mystream,myencode);
string
str
=
objReader.ReadToEnd();
转载于:https://www.cnblogs.com/ggbbeyou/archive/2009/01/09/1372595.html