DelphiFAQ Home Search:

How can I display a file selection box with C++ in .NET?

 

commentsThis 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) {

// debugging message box
	System::Windows::Forms::MessageBox::Show("Your PEPCost file will be saved.",
		saveFileDialog1->FileName,
		MessageBoxButtons::OK,
		MessageBoxIcon::Information);
}

saveFileDialog1->Dispose();

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.