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;
}
}
查看全文
相关阅读:
微软发布了Java Lang Conversion Asst 3.0测试版
关于GC的使用
增加了简单的搜索功能
[推荐]TreeView专题讨论
我是这样过大年初一的!
[推荐]动态加载类(在程序中调用DLL文件)
请大家正确填写自己的邮件地址
Microsoft Win32 to Microsoft .NET Framework API Map
奇怪的问题
发表含有HTML代码的文章时,请保持HTML代码的完整
原文地址:https://www.cnblogs.com/wbcms/p/1037566.html
最新文章
笔记本常用测试软件
Delphi 与 DirectX 之 DelphiX(36): TDIB.Contrast();
Delphi 与 DirectX 之 DelphiX(41): TDIB.SplitBlur();
Delphi 与 DirectX 之 DelphiX(39): TDIB.Sharpen();
Delphi 与 DirectX 之 DelphiX(34): TDIB.Lightness();
Delphi 与 DirectX 之 DelphiX(40): TDIB.Rotate();
Delphi 与 DirectX 之 DelphiX(42): TDIB.GaussianBlur();
Delphi 与 DirectX 之 DelphiX(35): TDIB.Saturation();
Delphi 与 DirectX 之 DelphiX(38): TDIB.Filter();
Delphi 与 DirectX 之 DelphiX(37): TDIB.AddRGB();
热门文章
Delphi 与 DirectX 之 DelphiX(43): TDIB.DoInvert;
如何发布公告
关于改进插入图片功能的想法
现在可以插入MSN表情了
今天开始上班了
ServerVariables["LOGON_USER"]在.NET Framework 1.1中不支持中文用户名的问题
推荐一个Blog桌面工具blogjet
在Windows下运行UNIX程序
DataGrid, DataList and Repeater
推荐一篇用Blog开发企业信息系统的文章
Copyright © 2011-2022 走看看