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;
}
}
查看全文
相关阅读:
Android studio导入开源项目
使用Kindeditor上传图片
IOS实现自动循环滚动广告--ScrollView的优化和封装
Android开发之Drag&Drop框架实现拖放手势
IOS中的手势详解
Android实现图片轮显效果——自定义ViewPager控件
IOS欢迎界面Launch Screen动态加载广告
tomcat 启动参数 Xms, Xmx, XX:MaxNewSize, XX:PermSize, -XX:MaxPermSize, Djava.awt.headless
PHP提升echo, printf, print, file_put_contents等输出方法的效率
WIN7下强制分第四个主分区的方法
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
很多年以后
通过 SMB 直通优化文件服务器的性能
转帖:数据库集群技术漫谈
[转]没有了SA密码,无法Windows集成身份登录,DBA怎么办?
How to Allow MySQL Client to Connect to Remote MySql
消息推送介绍
[转帖]DAS、NAS、SAN、iSCSI 存储方案概述
实现二值图像连通区标记之区域生长法
Emgu学习之(四)——图像阈值
七种常见阈值分割代码(Otsu、最大熵、迭代法、自适应阀值、手动、迭代法、基本全局阈值法)
热门文章
EmguCV 一些基本操作
[EmguCV|WinForm] 使用EmguCV內建直方圖工具繪製直方圖(Histogram)-直方圖(Histogram)系列 (1)
RBAC权限设计
用GDB调试程序(一)
gcc编译与gdb调试简要步骤
omnet++5.0安装使用
我所了解的cgi
Android制作曲线、柱状图、饼形等图表——使用AChartEngine
IOS中的动画——Core Animation
使用swipemenulistview实现列表的左右滑动
Copyright © 2011-2022 走看看