Example #1
0
 /// <summary>
 /// 读取文件字节流
 /// </summary>
 /// <param name="templatePath">模板相对路径</param>
 /// <param name="encode">页面编码</param>
 /// <returns>template静态模板的html字符串</returns>
 private static string ReadTemplateFile(string templatePath, string encode)
 {
     try
     {
         Encoding code = Encoding.GetEncoding(encode);
         if (DirFileHelper.IsExistFile(templatePath))
         {
             //读取
             using (_sr = new StreamReader(templatePath, code))
             {
                 return(_sr.ReadToEnd());
             }
         }
     }
     catch (Exception)
     {
         return("");
     }
     finally
     {
         if (_sr != null)
         {
             _sr.Close();
         }
     }
     return("");
 }
Example #2
0
        static MailHelper()
        {
            string templatePath = "Template\\eamil_template.html";

            //保存静态文件的路径
            string realPath = DirFileHelper.MapPath(templatePath);

            //模板文件内容
            TemplateString = ReadTemplateFile(realPath, "UTF-8");
        }