Skip to content

How to save the content of a richtextbox in a new file

herbert tamayo

Asked May 12, 2007, 3:06 PM EDT1 answer
Share
LinkedInX
hello, i´m tryin to save the content of a richtextbox in a new file using a function in c sharp similar to visual basic getfile() function, basically i need to save the content of a richtextbox in a new file and then if the user wants recall this file, can you hekp me what function i need to use?

trhanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    Use LoadFile, SaveFile (it saves in rtf (rich text format))

    From MSDN:

    [C#]
    public void CreateMyRichTextBox()
    {
        RichTextBox richTextBox1 = new RichTextBox();
        richTextBox1.Dock = DockStyle.Fill;


        richTextBox1.LoadFile("C:\\MyDocument.rtf");
        richTextBox1.Find("Text", RichTextBoxFinds.MatchCase);

        richTextBox1.SelectionFont = new Font("Verdana", 12, FontStyle.Bold);
        richTextBox1.SelectionColor = Color.Red;

        richTextBox1.SaveFile("C:\\MyDocument.rtf", RichTextBoxStreamType.RichText);

        this.Controls.Add(richTextBox1);
    }
    0