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;
}
}
查看全文
相关阅读:
CENTOS7下安装REDIS
目录结构和文件路径
bash特性
(十六)MySQL集群galera实现
(十五)mysql中间件MyCAT实现
(4)三剑客之awk
(十四)基于GTID的主从复制
(十三)MySQL主从复制
(3)三剑客之sed
(十二)MySQL逻辑备份mysqldump
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
Activity 启动模式
Android-Activity
python局部变量与全局变量
10.26日面试总结
mysql 多表连接查询
pandas常用操作
pandas过滤包含特定字符串的行
2017.10.23面试总结
mac 安装 word2016并破解
10.19日笔试总结
热门文章
10.17日面试总结
面试总结
iptables详解
linux web站点常用压力测试工具httperf
mysql数据恢复
mysql中大数据表alter增加字段报错:"1034 Incorrect key file for table 'table_name'; try to repair it"
MySQL中大数据表增加字段,增加索引实现
使用FIO工具测试块存储性能
PgSQL备份
网络性能测试方法
Copyright © 2011-2022 走看看