Answer the question
In order to leave comments, you need to log in
How to fix incorrect saving of text from RichTextBox to RTF file?
Saving text from the RichTextBox component to an RTF file does not work correctly. What is interesting: when stepping through the code, saving is performed, but during a normal launch it is not (the file is empty). What could be the problem?
if (richTextBoxWrite.Text != null)
{
SaveFileDialog sfd = new SaveFileDialog();
// sfd.Filter = "RTF files|*.rtf";
sfd.Filter = "txt files (*.rtf) | *.rtf | All files(*.*) | *.*";
if ((sfd.ShowDialog() == DialogResult.OK) && (sfd.FileName.Length > 0))
{
string filename = sfd.FileName;
richTextBoxWrite.SaveFile(filename, RichTextBoxStreamType.RichText);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question