CFileDialog class that only displays folders

Download Source Code and Example

The CFolderDialog class is derived from CFileDialog. The major difference between
the two classes is that while the CFileDialog class displays both folders and files,
the CFolderDialog class can be used in situations where the application only wants
to display folders. Below is a code snippet showing how easy it is to use this class.
Please note that the the constructor for the CFolderDialog takes a CString pointer.
This variable will contain the name of the folder that was selected by the end user
when the DoModal function call returns.


CString pathSelected;
CFolderDialog dlg(&pathSelected);
if (dlg.DoModal() == IDOK)
{
// pathSelected contain the selected folder.
AfxMessageBox(pathSelected);
}

Last updated: 29 April 1998

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read