C# Visual Studio 2005中操作RTF

1、C# Visual Studio 2005中RichTextBox保存文件为rtf格式

 

C# Visual Studio 2005中RichTextBox保存文件为rtf格式
SaveFileDialog saveFile1 = new SaveFileDialog();
// Initialize the SaveFileDialog to specify the RTF extention for the file.
saveFile1.DefaultExt = "*.rtf";
saveFile1.Filter = "RTF Files|*.rtf";

// Determine whether the user selected a file name from the saveFileDialog.
if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
               saveFile1.FileName.Length > 0)
{
    // Save the contents of the RichTextBox into the file.
            richTextBox1.SaveFile(saveFile1.FileName);

 

2、 C# Visual Studio 2005中RichTextBox打开文件为rtf格式

 

C# Visual Studio 2005中RichTextBox打开文件为rtf格式
string str;
openFileDialog1.DefaultExt = "*.rtf";
openFileDialog1.Filter = "Text.File(*.rtf)|*.rtf|All File(*.*)|*.*";
openFileDialog1.ShowDialog();
str = openFileDialog1.FileName;
richTextBox1.LoadFile(str); 

你可能感兴趣的:(C++,c,windows,C#)