Skip to content

How to save contents of an edited richtextbox on a C# form

zixing wang

Asked Sep 12, 2008, 6:40 AM EDT2 answers
Share
LinkedInX

I editted and saved a richtextbox contents that was loaded from a text file using the following codes but it does not work. Anyone can help me.

TypeScript
private void btnSave_Click(object sender, EventArgs e)
{
rtbData.Enabled = true;
rtbData.Update();
rtbData.SaveFile("c:/DDE_Log1.txt", RichTextBoxStreamType.PlainText);
}

2 Answers

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

  • +1
    I just re-created what I think you are talking about (a RichTextBox and a Button) and copied the code you posted into the click handler and it worked for me. Could you provide some more details on what exactly doesn't work for you?
    +1
  • +1

    John:

    It looks strange. After I created a new text file and linked to my codes, it works just fine.

    I looked the trouble text file. It was not set as readonly and I was able to edit it using NotePad. Do you have any  idea for the possible cause.

    Thanks

    +1