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;
}
}
查看全文
相关阅读:
select()函数用法二
fcntl函数的用法总结
O_NONBLOCK与O_NDELAY有何不同?
struct termios结构体详解
select()函数用法一
linux下的struct sigaction
sigaction 用法实例
nand flash 的oob 及坏块管理
wifi两种工作模式
UBIFS文件系统简介 与 利用mkfs.ubifs和ubinize两个工具制作UBI镜像 (完整理解版本)
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
同步fifo的Verilog实现
ZedBoard上运行linux系统的准备工作框架
ubuntu上make menuconfig出错
ubuntu上设备树的编译
ubuntu上编译linux内核
INTEST/EXTEST SCAN 的学习
IC 设计中DFT的Boundary Scan功能
a no-risk path to IEEE P1687
S0到S5状态讲解
指令缓存
热门文章
关于 AXI协议的学习解释说明
Low Power之CPF/UPF
Verdi文档路径
MBIST:用于嵌入式存储器的可测试设计技术
DC综合及仿真验证和DFT测试
REX系统2
REX系统了解1
select()函数用法三之poll函数
linux下C获取系统时间的方法
sleep允许休眠, delay不允许
Copyright © 2011-2022 走看看