Как я могу сохранить файл в другом формате? - PullRequest
0 голосов
/ 12 августа 2011

У меня быстрый вопрос, как сохранить файл в другом формате, как в «сохранить как»

пока я получил это

   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);

Я хочу иметь возможность сохранять как эфир формат RTF или TXT. спасибо.

1 Ответ

1 голос
/ 12 августа 2011

Используйте имя файла с другим именем и передайте его в SaveFile с буфером чтения содержимого из файла origianl.

...