File View Dialog Using Winforms and Managed C ++

I am working on Managed C ++ for the first time ... I created a form using Winform, which has a button for viewing directories for a file and any path that the user selects, the path should be visible in the text box.

I wanted to know how to create a file browser dialog in Managed C ++.

Attach a shape image if required. enter image description here

+4
source share
1 answer

Are you looking for OpenFileDialog or SaveFileDialog .

void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { Stream^ myStream; OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog; openFileDialog1->InitialDirectory = "c:\\"; openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog1->FilterIndex = 2; openFileDialog1->RestoreDirectory = true; if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { if ( (myStream = openFileDialog1->OpenFile()) != nullptr ) { // Insert code to read the stream here. myStream->Close(); } } } 
+5
source

All Articles