Programming C# C++ (7) Delphi (604) Java (8) JavaScript (55) perl (40) php (12) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us
|
How can I display a file selection box with C++ in .NET?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
You need to instantiate an object of the SaveFileDialog class. Prepare the file selection filter and then display the modal dialog with the ShowDialog() call.
The selected filename can be retrieved as the FileName member. You can also preset this member.
Alternatively you could drop such a component on your application's form and set the properties there.
Personally, I prefer to create this kind of object dynamically and get rid of it right away.
 | |  | | SaveFileDialog* saveFileDialog1 = new SaveFileDialog();
saveFileDialog1->Filter = S"PEPCost files (*.pc)|*.pc|All files (*.*)|*.*" ;
saveFileDialog1->FilterIndex = 1;
saveFileDialog1->RestoreDirectory = true;
if(saveFileDialog1->ShowDialog() == DialogResult::OK) {
System::Windows::Forms::MessageBox::Show("Your PEPCost file will be saved.",
saveFileDialog1->FileName,
MessageBoxButtons::OK,
MessageBoxIcon::Information);
}
saveFileDialog1->Dispose(); | |  | |  |
Comments:
|