dotnet中如何把html代码(或者比较html文件也可以)转换成字符串(单个字符串)
解决方案 »
- 我想做一个电影院订票系统,该有哪些表呢?
- 一个小问题,高手来解决,在线等
- string userName = Request.Form["txtName"].ToString();问题?
- 这网页为什么刷新也调用按钮函数?
- FCKeditor使用问题
- !!子窗口向父窗口提交数据的问题
- 怎样取出数据库的内容实现这样的效果?
- 控件开发:如何做一个能弹出选择图片对话框的属性?
- 毕业论文要写一个基于.NET的bbs论坛的系统,跪求帮助
- 请教各位大虾:在 DataGrid 中怎样把 2002-2-12 0:00:00 格式化为 2002-2-12。
- 报表的奇怪的问题
- 让几个技术的同行看过我的项目,都说是用控件堆砌的,什么意思呀?
httpwebRequest /// <summary>
/// 根据Url地址获取给地址的返回的所有内容,该内容为字符串
/// </summary>
/// <param name="Url">合法存在的Url地址</param>
/// <param name="encodestr">对该内容采取的html编码</param>
/// <returns></returns>
public string GetUrlContent(string Url, Encoding encodestr)
{
string result=null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
try
{
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, encodestr);
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
while (count>0)
{
String str = new String(read, 0, count);
result += str;
count = sr.Read(read, 0, 256);
}
return result;
}
catch(Exception ex)
{
throw ex;
}
finally
{
if (response!=null)
response.Close();
}
}