且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在fastcoloredtextbox中保存文件?

更新时间:2023-09-28 11:30:10

您应该执行其他建议,将其另存为扩展名为.html的文本文件,但是我在这里回答您的问题.假设您使用的是Winform(因为尚未指定):

You should do what the others suggested about saving it as a text file with a .html as extension as well, but I'm here to answer your ctrl + s question. This is assuming you're on a winform (because you haven't specified yet):

yourForm.KeyPreview = true;
yourForm.KeyDown += new KeyEventHandler(Form_KeyDown);

您的处理程序应如下所示:

and your handler should look something like this:

    void Form_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Control && e.KeyCode == Keys.S)
        {
            string sourceCode = FastColoredTextBox1.Text;
            // not sure what's going on for you "location" but you need to do that logic here too
            File.WriteAllText(location, sourceCode);
            e.SuppressKeyPress = true;
        }
    }

希望发芽的希望