例如:
private void btnSave_Click(object sender, System.EventArgs e)
{
//Show dialog to open file
OpenFileDialog saveFile1=new OpenFileDialog();
saveFile1.DefaultExt = "*.rtf";
saveFile1.Filter = "RTF Files|*.rtf";
// get a file name from the user
if(saveFile1.ShowDialog() == DialogResult.OK)
{
// Save the RTF contents of the RichTextBox control that
// was dragged onto the Window Form and populated somehow
rtbTest.SaveFile(saveFile1.FileName,
RichTextBoxStreamType.RichText);
//use to save RTF tags in file
}
}
private void btnSave_Click(object sender, System.EventArgs e)
{
//Show dialog to open file
OpenFileDialog saveFile1=new OpenFileDialog();
saveFile1.DefaultExt = "*.rtf";
saveFile1.Filter = "RTF Files|*.rtf";
// get a file name from the user
if(saveFile1.ShowDialog() == DialogResult.OK)
{
// Save the RTF contents of the RichTextBox control that
// was dragged onto the Window Form and populated somehow
rtbTest.SaveFile(saveFile1.FileName,
RichTextBoxStreamType.RichText);
//use to save RTF tags in file
}
}
string strFileName=yourFileName;
rtbTest.SaveFile(strFileName,
RichTextBoxStreamType.RichText);