Posted on 2006-07-06
I want to be able to select a folder on my HD and put the path into a text field. This should be easy enough except I can't get the CFileDialog to allow me to just select a folder. It needs me to select a file. I assume there's a flag that specifies you don't need to select a file, but I can't figure out what the flag is. I've checked msdn and can't see it. I have done it easily enough before with Win32, but can't seem to get CFileDialog to do it.
I tried creating the dialog as follows:
CFileDialog SourceFile(TRUE, NULL, NULL, !OFN_FILEMUSTEXIST);
All this does is specify that the file doesn't have to be there. This way, I can navigate to the folder, type in any randon gibberish, and when the dialog closes, extract the folder path. This is a little messy and would rather be able to just select the folder.
Any ideas what I'm doing wrong?