zoukankan
html css js c++ java
个人学习代码保存:例10.通过模板创建静态页面的操作文件的一个自定函数
操作文件的一个自定函数:
using
System;
using
System.Data;
using
System.Configuration;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.IO;
//
文件操作
using
System.Text;
//
编码操作
/**/
///
<summary>
///
Files 的摘要说明
///
</summary>
public
class
Files
{
public
Files()
{
//
//
TODO: 在此处添加构造函数逻辑
//
}
public
static
bool
CreatHtmlPage(
string
[] strNewHtml,
string
[] strOldHtml,
string
strModelFilePath,
string
strHtmlFilePath)
{
bool
Flag
=
false
;
StreamReader ReaderFile
=
null
;
StreamWriter WriterFile
=
null
;
string
FilePath
=
HttpContext.Current.Server.MapPath(strModelFilePath);
Encoding code
=
Encoding.GetEncoding(
"
GB2312
"
);
string
strFile
=
string
.Empty;
try
{
ReaderFile
=
new
StreamReader(FilePath, code);
strFile
=
ReaderFile.ReadToEnd();
}
catch
(Exception ex)
{
throw
ex;
}
finally
{
ReaderFile.Close();
}
try
{
int
intLengTh
=
strNewHtml.Length;
for
(
int
i
=
0
; i
<
intLengTh; i
++
)
{
strFile
=
strFile.Replace(strOldHtml[i], strNewHtml[i]);
}
WriterFile
=
new
StreamWriter(HttpContext.Current.Server.MapPath(strHtmlFilePath),
false
, code);
WriterFile.Write(strFile);
Flag
=
true
;
}
catch
(Exception ex)
{
throw
ex;
}
finally
{
WriterFile.Flush();
WriterFile.Close();
}
return
Flag;
}
}
查看全文
相关阅读:
POJ-3176 Cow Bowling
01背包、完全背包、多重背包
最后的几天暑假学习
暑假的学习
凸包算法(Graham扫描法)详解
微软版的SqlHelper.cs类
SQL语句分组排序,多表关联排序
SQL存储过程分页(通用的拼接SQL语句思路实现)
增加删除字段修改字段名,修改表结构,非常用SQL语句技巧总结
Asp.net mvc返回Xml结果,扩展Controller实现XmlResult以返回XML格式数据
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
CSS_字体属性
4.Linux文件管理相关命令(上)
3.Linux目录结构与文件管理
2.Linux Bash认识
3. Rsync-远程同步(下)-企业案例
2. Rsync-远程同步(上)
网络运维必备
1. 综合架构基本概述
OSI七层模型和五层TCP/IP协议
报错总结
热门文章
Dell R720 RAID配置
关于缓存穿透,缓存击穿,缓存雪崩,热点数据失效问题的解决方案(转)
memcache和redis缓存对比及我为什么选择redis
cpu开多少线程合适(转)
路由器和交换机的区别
POJ 3280 Cheapest Palindrome
2018牛客多校第二场a题
POJ 3616 Milking Time
POJ 2385 Apple Catching
POJ 2229 Sumsets
Copyright © 2011-2022 走看看