RichTextBox SaveFile()

时间:2013-04-06 21:17:29

标签: c++ richtextbox

如何将字符串作为路径传递到此处

 void SaveLogFile()
         {              
             logTxt->SaveFile(String::Concat
                 (System::Environment::GetFolderPath
                (System::Environment::SpecialFolder::Personal),                                         
                 "\\Testdoc.rtf"), RichTextBoxStreamType::RichNoOleObjs);
         }

我无法弄清楚如何设置非SpecialFolder

1 个答案:

答案 0 :(得分:0)

来自MSDN

void SaveMyFile()
   {
      // Create a SaveFileDialog to request a path and file name to save to.
      SaveFileDialog^ saveFile1 = gcnew 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 );
      }
   }

了解如何在此处创建System::String^。这样做也是这样......