如何以不同格式保存文件?

时间:2020-11-26 22:47:46

I have a quick question, how do you save a file in a different format like in "save as"

我有一个简单的问题,你如何以不同的格式保存文件,如“另存为”

so far i got this

到目前为止我得到了这个

   private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    {
        //this saves the file as a text or richtext. 
        saveFileDialog1.Filter = ("RichText*.rtf; )|*.rtf; |TextDocs *.txt;|*.txt");

        saveFileDialog1.FilterIndex = 2;
        //this gives the title of the savefiledialog.
        saveFileDialog1.Title = "save file";
        //this prompts the user if they want to overwrite an existing file.
        saveFileDialog1.OverwritePrompt = true;
        //gets the input made by the savefiledialog.
        if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            //saves the file.
            richTextBox1.SaveFile(saveFileDialog1.FileName,
                //saves the text in the richbox
                RichTextBoxStreamType.RichText);

I want to be able to save as ether a rtf or a txt format. thanks.

我希望能够以ether为rtf或txt格式保存。谢谢。

1 个解决方案

#1


1  

Use filename different name and pass it to SaveFile with the read content buffer from origianl file.

使用filename不同的名称,并使用origianl文件中的读取内容缓冲区将其传递给SaveFile。

#1


1  

Use filename different name and pass it to SaveFile with the read content buffer from origianl file.

使用filename不同的名称,并使用origianl文件中的读取内容缓冲区将其传递给SaveFile。

相关文章