Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

How to save the text file in the Documents folder

$
0
0

In a CLR project, windows form,I use SaveFileDialog control and richTextBox->LoadFile  to save a text file:

private: System::Void viewlog_Load(System::Object^ sender, System::EventArgs^ e) { richTextBox1->LoadFile("log.txt",RichTextBoxStreamType::PlainText); } private: System::Void button1_Click(System::Object^sender, System::EventArgs^ e) { saveFileDialog1->ShowDialog(); if(saveFileDialog1->FileName != "") {

richTextBox1->SaveFile(saveFileDialog1->FileName,

RichTextBoxStreamType::PlainText); } }

The Savefile control opens of default in installation folder. (Of course the user can change the folder manually).
How can I make because the control is opened by default in the Documents folder?
The sample code of VS Help does not work:

public:
   void SaveFile()
   {
      // You should replace the bold file name in the 
      // sample below with a file name of your own choosing.
      richTextBox1->SaveFile(String::Concat
         (System::Environment::GetFolderPath
         (System::Environment::SpecialFolder::Personal),"\\Testdoc.rtf"), RichTextBoxStreamType::RichNoOleObjs);
   }

The "GetFolderPath" and "SpecialFolder::Personal"  are not recognized by the compiler.

I work with VCExpress2010 and xp.


beginner of planning



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>