示例#1
0
        public string Load()
        {
            if (_templatePath != "")
            {
                try
                {
                    TemplateData = "";

                    if (File.Exists(_templatePath))
                    {
                        string inputLine;
                        var    inputStream  = new FileStream(_templatePath, FileMode.Open, FileAccess.Read);
                        var    streamReader = new StreamReader(inputStream);

                        while ((inputLine = streamReader.ReadLine()) != null)
                        {
                            TemplateData += inputLine + Environment.NewLine;
                        }
                        streamReader.Close();
                        inputStream.Close();

                        if (TemplateData.Contains("**CDATASTART**"))
                        {
                            //convert back cdata marks converted so it saves OK into XML
                            TemplateData = TemplateData.Replace("**CDATASTART**", "<![CDATA[");
                            TemplateData = TemplateData.Replace("**CDATAEND**", "]]>");
                        }
                        IsTemplateFound = true;
                    }
                    else
                    {
                        TemplateData = "";
                    }
                }
                catch (Exception)
                {
                    TemplateData = string.Format("ERROR ON TEMPLATE READ ({0})", TemplateName);
                }
            }

            return(TemplateData);
        }