///
/// 读取模板的内容
///
/// 模板路径
///
public static string ReadFile(string tempDir)
{
if(File.Exists(System.Web.HttpContext.Current.Request.PhysicalApplicationPath+tempDir))
{
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + tempDir, System.Text.Encoding.Default);
string str = sr.ReadToEnd();//读取目前位置到数据流末端之间的数据流
sr.Close();
return str;
}
return "未找到模板文件:" + tempDir;
}
///
/// 创建目录
///
///
public static void CreateDir(string dir)
{
if (dir.Length == 0) return;
if (!Directory.Exists(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "//" + dir))
Directory.CreateDirectory(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "//" + dir);
}
///
/// 读取新闻模板内容
///
///
///
public static void CreateFile(string dir, string pagestr)
{
dir = dir.Replace("/", "//");
if (dir.IndexOf("//") > -1)
CreateDir(dir.Substring(0, dir.LastIndexOf("//")));
System.IO.StreamWriter sw = new System.IO.StreamWriter(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "//" + dir, false, System.Text.Encoding.GetEncoding("GB2312"));
sw.Write(pagestr);
sw.Close();
}