Strange text appearing on page after saving a file

Asked

Viewed 65 times

0

I’m creating a C#text editor, but when I saved a file .html, on the page appeared this error

SS

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace onedev
{
    public partial class Form1 : Form
    {
        string language; 

        public Form1()
        {
            InitializeComponent();
        }
        private void hTMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            language = "HTML";
            codding.Text += "<!DOCTYPE html><html> <head><title>Hello world</title></head> <body><h1>Hello World!</h1></body></html>";
        }

        private void htmlToolStripMenuItem1_Click(object sender, EventArgs e)
        {

        }

        private void salvarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (language == "HTML")
            {
                SaveFileDialog saveHtml = new SaveFileDialog();
                saveHtml.DefaultExt = "*.html";
                saveHtml.Filter = "HTML|*.html";

                if (saveHtml.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                   saveHtml.FileName.Length > 0)
                {
                    codding.SaveFile(saveHtml.FileName);
                }
            }
        }
    }
}
  • 1

    I find it hard to help you without looking at any code, but since I don’t understand C# ...

  • Only with this excerpt still seems to be complicated to offer some solution. We need more information, more relevant excerpts. Do not forget that the correct is [Dit] the question to put the new excerpt.

  • edited code.

  • 1

    by chance "codding" is RTF text editor of Windows Forms?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.