我要用,net生成静态网页 能否给点代码
解决方案 »
- DataGridViewRow与datatable的关联小问题
- 怎么讲文本的内容存入内存
- Asp.net与Access的DataReader分页(cool!最新献上~)
- 关闭异常
- dllimport问题
- [Web]请教如何实现网格分组显示数据,用asp.net
- C/S与B/S的结合
- C# winform下调取不同程序集下的config文件?求助高手!!!
- 关于c# 和 matlab的问题
- 请问怎样刷新一个treeview的node?
- 如何取数字的个位数!!!在线等待急!!!!!!
- BUTTON的click事件中不能执行Response.Write("<script language=javascrip> alert('hello');</script>");
以前做网站用到了那个。联系我 email:[email protected]
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace YiYao58
{
/*
* 目前只在html文件中进行过测试
* ReadFile读取文件要求完整的路径
*
* Replace用于替换文件里面的内容
* CreateDire 用于创建文件夹
* WriteFile创建文件和文件夹
* DelFile 删除文件夹以及里面的内容
* */
public class CreateFile
{
StringBuilder htmltext = new StringBuilder();
//读取文件
public void ReadFile(string FileName)
{
try
{ using (StreamReader sr = new StreamReader(FileName,Encoding.UTF8))
{ String line; while ((line = sr.ReadLine()) != null)
{ htmltext.Append(line); } sr.Close(); } } catch
{ }
}
//替换内容
public void Replace(string oldText,string newText)
{
htmltext.Replace(oldText, newText);
}
//创建文件
public void WriteFile(string FileName)
{
try
{ using (StreamWriter sw = new StreamWriter(FileName, false, System.Text.Encoding.UTF8))
{ sw.WriteLine(htmltext); sw.Flush(); sw.Close(); } } catch
{ }
}
//创建文件夹和文件
public void CreatFile(string FileName,string Path)
{
try
{
if (!Directory.Exists(Path))
{
Directory.CreateDirectory(Path);
} WriteFile(Path +"\\"+ FileName); }
catch
{ }
}
//创建文件夹
public void CreateDire(string Path)
{
try
{
if (!Directory.Exists(Path))
{
Directory.CreateDirectory(Path);
}
}
catch
{
}
}
//删除文件
public void DelFile(string Path)
{
try
{
if (Directory.Exists(Path))
{
Directory.Delete(Path, true);
}
}
catch
{
} }
}
}
http://www.cnblogs.com/yefei520/archive/2006/02/14/330163.html