public static TemplateInfo GetTemplate(string templatesPath, string templateName) { TemplateInfo templateInfo = null; string templateFolder = (templatesPath + TemplateFolder); try { if (Directory.Exists(templateFolder)) { string file = templateFolder + templateName; if (File.Exists(file)) { FileInfo fileInfo = new FileInfo(file); StreamReader reader = new StreamReader(fileInfo.FullName); templateInfo = new TemplateInfo(); templateInfo.Name = fileInfo.Name; templateInfo.Path = fileInfo.FullName; templateInfo.Content = reader.ReadToEnd(); reader.Close(); } } } catch { //Ignore any errors } return templateInfo; }
public static ArrayList GetTemplates(string templatesPath) { ArrayList templateList = new ArrayList(); string templateFolder = (templatesPath + TemplateFolder); if (Directory.Exists(templateFolder)) { string[] fileList = Directory.GetFiles(templateFolder, "*.htm"); foreach(string file in fileList) { FileInfo fileInfo = new FileInfo(file); StreamReader reader = new StreamReader(fileInfo.FullName); TemplateInfo templateInfo = new TemplateInfo(); templateInfo.Name = fileInfo.Name; templateInfo.Path = fileInfo.FullName; templateInfo.Content = reader.ReadToEnd(); templateList.Add(templateInfo); reader.Close(); } } return templateList; }