1

I have converted a MFC application which was run on VS2005 to VS2010 In there I've functionality to select either a file or folder from CSelectDialog and it worked fine.

But when I convert the project into VS2010 now I can select files only. How can I get rid of that? I couldn't find any libraries that I can use for this.

Simply I want to select either a file or folder using MFC in VS2010

Don't consider this as a duplication of

https://stackoverflow.com/questions/15852106/how-to-use-open-file-dialog-to-select-either-a-file-or-a-folder-in-vc-mfc

or

How do you configure an OpenFileDialog to select folders?

Because those answers are not applicable to this.

1
  • 4
    I think you need to expound a bit more on why those questions aren't dupes, and why those answers don't apply here. You need to show how your question is different, not just say you don't like/can't use those answers. Commented Dec 9, 2013 at 6:26

2 Answers 2

2

The source has a lot of assumptions about the types and ids of child controls on the file dialog. And the assumptions are broken if the file dialog upgraded to vista style. You can use the bVistaStyle parameter in the constructor to disable the automatic upgrade.

SHBrowseForFolder with BIF_BROWSEINCLUDEFILES is the only documented way I know of to choose file and folder at once. You can also consider supporting Shell Data Transfer between Windows Explorer and your program (e.g. drag/drop, copy/paste).

Sign up to request clarification or add additional context in comments.

Comments

1

It looks like you're using some code from CodeProject that may not be compatible with 2010. You should use the standard CFileDialog to avoid any compatibility issues.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.