2011-08-12 10 views
0

私は簡単な質問、どのようにあなたがこれまでのところ、私はこのファイルを別の形式で保存するにはどうすればよいですか?

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

私はエーテルAとして保存することができるようにしたいしまった

「名前を付けて保存」のような別の形式でファイルを保存するかを持っていますrtfまたはtxt形式です。ありがとう。

答えて

1

別のファイル名を使用し、origianlファイルから読み込んだコンテンツバッファでSaveFileに渡します。

+0

私に例を挙げてもらえますか?私はまだC#の新機能です。 – mendez

+0

saveasile操作を行うときに、saveFileDialog1.FileName変数の代わりに別のファイル名を指定します。 – Zenwalker

+0

ありがとう私はそれを得た!私はそれが単純だとは信じられません:P – mendez

関連する問題