龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp.net编程 >

asp.net读写文件与建立目录简单函数

时间:2009-12-21 11:47来源:未知 作者:admin 点击:
分享到:
//写入文件 using (StreamWriter sw = new StreamWriter(filePath, false)) { sw.Write(xmlSTR); sw.Dispose(); } //读取文件内容 public static string ReadHtml(string Path) { string result = string.Empty; if (File.Exists(Path)) { try { usi
//写入文件
using (StreamWriter sw = new StreamWriter(filePath, false))
{
 sw.Write(xmlSTR);
 sw.Dispose();
}
//读取文件内容
public static string ReadHtml(string Path)
{
 string result = string.Empty;
 if (File.Exists(Path))
 {
  try
  {
   using (StreamReader sr = new StreamReader(Path))
   {
    result = sr.ReadToEnd();
   }
  }
  catch
  { }
 }
 else
 {
  result = "模板不存在!";
 }
 return result;
}
//建立目录
public static void CreateDirectory(string Path)
{
 if (!Directory.Exists(Path))
 Directory.CreateDirectory(Path);
}
精彩图集

赞助商链接