I am creating a text editor in C #, but when I saved a file .html
, on the page appeared that error
Code:
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceonedev{publicpartialclassForm1:Form{stringlanguage;publicForm1(){InitializeComponent();}privatevoidhTMLToolStripMenuItem_Click(objectsender,EventArgse){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);
}
}
}
}
}