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;
}
}
查看全文
相关阅读:
寫程序方法
phpDesigner注冊碼
如何获取SQL Server数据库元数据(转)
WPF中的事件(Event)
访问数据源的架构信息(系统表、信息结构图、GetSchema)
MSbuild生成WPF程序
数据契约
window动态调整大小后无法关闭
sql server 2000 系统表详细介绍(转,收藏一下)
Linq2Sql:使用Sqlmetal.exe
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
【转】forcing Eclipse to work with Linux kernel (indexing kernel source)
C# 中的var关键字
jquery 字符串切割 函数 substring 用法
中小型网络项目建设案例[转51CTO]
SQLServer基本函数
Douban的jquery使用技巧[转载]
asp.net 在线人数统计,页面访问量 Application ,session
Jquery + Ajax 调用 webService(转)
jquery取值
Jquery截取中文字符串
热门文章
javascript弹出窗口
jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关
解决Incorrect integer value: '' for column 'id' at row 1
Navicat for mysql 9.0.15 注册码
不可思议的强身健心的方法——甩手练气念佛持咒
如何删除ckeditor的状态栏
MySQL中的LOCATE和POSITION函数使用方法
PHP ksort() 函数
phpmyadmin设置登陆的方式
如何提高自己的编程能力
Copyright © 2011-2022 走看看