2013-04-06 46 views
0

我怎麼能傳遞一個字符串作爲路徑到這裏RichTextBox的SAVEFILE()

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

我無法弄清楚如何設置非SpecialFolder

回答

1

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^。這樣做也是...

+0

當然。漫長的一天...... :) 謝謝 – Mike 2013-04-06 21:32:17