hi..
now i'm trying to use the openfiledialog in a gui app .. what i have done till now is that
1. open visual stdio 2008
2. select c++ project
3. select windows application project
4. drag the openfile dialog from tool box and drop it on the form .. then i stopped coz i don't know what should i do after that

plz any one can help me !!

Within the body of a button click method (of a button with the text "Open" or some such)

openFileDialog1->InitialDirectory = "C:\\";  //set the initial directory for the dlg
openFileDialog1->Filter = "All Files(*.*)|*.*"; //set a filter for the types of files
openFileDialog1->FileName = ""; //leave the textbox blank
Windows::Forms::DialogResult dr = openFileDialog1->ShowDialog(); //show the dialog

After that, compare dr with Windows::Forms::DialogResult::OK (need the fully qualified name) and openFileDialog1->FileName will contain the name file the user selected. Use this name, for instance, in a StreamReader call to open a text file.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog_members.aspx to get an idea of some of the other members that are available.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.