Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
WebHtmlEditor text saving
posted

Is there a way to save text from WebHtmlEditor to an html file? if so can you please show me an example.

Thank you

Naresh.

Parents
  • 155
    Verified Answer
    posted

    here is how to do it

      private void SaveTextEditorData()
            { 
                string fileName = "c:\\test1.html";

                FileStream outputfile = null;
                StreamWriter writer = null;

                try
                {
                    outputfile = new FileStream(fileName,FileMode.OpenOrCreate, FileAccess.Write);

                     writer = new StreamWriter(outputfile);

                    writer.BaseStream.Seek(0, SeekOrigin.End);
                    DoWrite("<HTML>", writer);
                    DoWrite("<HEAD>", writer);
                    DoWrite("<TITLE>", writer);
                    DoWrite("This HTML file is create in C#", writer);
                    DoWrite("</TITLE>", writer);
                    DoWrite("</HEAD>", writer);
                    DoWrite("<BODY>", writer);
                    DoWrite(this.uxFulfillmentPreviewWebHtmlEditor.TextXhtml, writer);
                    DoWrite("</BODY>", writer);
                    DoWrite("</HTML>", writer);
                    writer.Close();

                 }
                catch (Exception ex)
                {
                    outputfile = null;
                    writer = null;
                }
          
            }

            private void DoWrite(String line, StreamWriter writer)
            {
                writer.WriteLine(line);
                writer.Flush();
            }

     

Reply Children
No Data