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;
}
}
查看全文
相关阅读:
vscode 在linux中,切换语言模式快捷键
转载大神的一篇文章----【如何选择开源许可证?】
Kibana6.x.x——源码发布
Kibana6.x.x——【Running "run:optimizeBuild" (run) task】出现警告信息
linux系统为文件添加执行权限
Kibana6.x.x——执行yarn build出现的警告信息记录
Kibana6.x.x——导航权限控制入门
poj 2187:Beauty Contest(计算几何,求凸包,最远点对)
poj 2386:Lake Counting(简单DFS深搜)
蓝桥杯 第三届C/C++预赛真题(10) 取球游戏(博弈)
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
select 自定义样式插件 selectize.js
不定义JQuery插件,不要说会JQuery
Python 创建和使用类
Python 传递任意数量的实参
哨兵查找法(明解c语言) + 函数式宏
求1000以内的质数c语言
Discrete Log Algorithms :Baby-step giant-step
记录一次在centos下使用gmp的悲伤
python使用sessions模拟登录淘宝
Windows下命令行怎样登录MySQL
热门文章
快速幂模n运算
AES SBox的构造(python)
React笔记:ref注意事项
React应用程序设计过程中如何区分模块到底是state还是props?
React组件Components的两种表示方式
css样式继承经验记录
Kibana6.x.x---编译源码,在执行优化任务时,报警告
logstash根据配置文件启动时,报异常
nodejs創建目錄命令mkdir失敗
使用npm发布自己的包
Copyright © 2011-2022 走看看