没有合适的资源?快使用搜索试试~ 我知道了~
通过相关参数获取页面信息和生成静态页面
需积分: 9 4 下载量 148 浏览量
2011-04-13
20:44:07
上传
评论
收藏 3KB TXT 举报
温馨提示
试读
3页
在使用的过程中,请参考文件里面的,里面有两个方法,一个是获取数据,一个是生成页面,两个方法结合使用,详细的请下载,查看里面的信息
资源推荐
资源详情
资源评论
//导入命名空间 using System.Net;
//如果 要生成静态页面 请把下面两个方法结合使用 其中 htmlData 就是下面方法获取的数据
#region 生成指定虚拟路径的服务器静态页面 2011-4-1
/// <summary>
/// 生成指定虚拟路径的服务器静态页面 2011-4-1 1生成失败 2生成成功
/// </summary>
/// <param name="virFilePath">虚拟路径 比如 ~/index.html</param>
/// <param name="htmlData">请求的数据</param>
/// <param name="encode">请求的编码比如 UTF-8</param>
/// <returns></returns>
public string BuildHtmlFile(string virFilePath, string htmlData, string encode)
{
// ~/index.html 虚拟路径
try
{
string filePath = virFilePath;
string phyFilePath = HttpContext.Current.Server.MapPath(filePath);
if (System.IO.File.Exists(phyFilePath))
{
System.IO.File.Delete(phyFilePath);
}
System.IO.FileStream fs = System.IO.File.Create(phyFilePath);
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.GetEncoding(encode));
sw.WriteLine(htmlData);
sw.Close();
fs.Close();
sw.Dispose();
fs.Dispose();
//如果 要生成静态页面 请把下面两个方法结合使用 其中 htmlData 就是下面方法获取的数据
#region 生成指定虚拟路径的服务器静态页面 2011-4-1
/// <summary>
/// 生成指定虚拟路径的服务器静态页面 2011-4-1 1生成失败 2生成成功
/// </summary>
/// <param name="virFilePath">虚拟路径 比如 ~/index.html</param>
/// <param name="htmlData">请求的数据</param>
/// <param name="encode">请求的编码比如 UTF-8</param>
/// <returns></returns>
public string BuildHtmlFile(string virFilePath, string htmlData, string encode)
{
// ~/index.html 虚拟路径
try
{
string filePath = virFilePath;
string phyFilePath = HttpContext.Current.Server.MapPath(filePath);
if (System.IO.File.Exists(phyFilePath))
{
System.IO.File.Delete(phyFilePath);
}
System.IO.FileStream fs = System.IO.File.Create(phyFilePath);
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.GetEncoding(encode));
sw.WriteLine(htmlData);
sw.Close();
fs.Close();
sw.Dispose();
fs.Dispose();
资源评论
fzsdchenbigui
- 粉丝: 13
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功