Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFileDialog 2

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
i'm creating a CFileDialog to ask user to select a file
but i want to filter out and show only a certain extension of .dat files or to check if the extension is correct,
how do i code this? maybe using regular expression?

FILE *filename;
CString cs;
//open file
CFileDialog m_ldFile(TRUE);
if(m_ldFile.DoModal()==IDOK)
cs=m_ldFile.GetFileName();
filename = fopen(cs,"r");
UpdateData(FALSE);
 
Set the lpszFilter parameter of the constructor to a valid filter string for the file types you want displayed.

-pete
 
CFileDialog myDialog(TRUE, // file open; FALSE means "save
"pa", // default file extension
NULL, // file name to show initially OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "PA Files (*.pa)|*.pa|"); //this is the filter





Look at the code I've written above, this should be helpful. Replace the second and 4th arguments with the type of file you owuld like to filter to.

--Vivek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top