IFileSaveDialog - choosing folders in Windows 7
Asked Answered
L

2

7

In Vista, I have been using an IFileSaveDialog to let users pick a "save-as" folder. Users export a folder of images, say, and need to choose a new or existing target folder.

Briefly, the code goes like this:

IFileSaveDialog* dialog; // created
dialog->SetOptions(FOS_PICKFOLDERS);
dialog->Show(NULL);
dialog->GetResult(&shellItem)

In Windows 7, the FOS_PICKFOLDERS option appears to have been disallowed (and is marked as such in the API). The return value on the SetOptions call is E_INVALIDARG. If I use a IFileOpenDialog, I'm allowed to set the folders option, but the user is prompted with an error when choosing a nonexistent folder (despite my setting flags suggesting not to do this).

Is there an alternate way to get the new IFileDialog to act as a "save folder" dialog?

[To head off some comments, the SHBrowseForFolder API still exists, but is still not an acceptable solution for our UI deciders.]

Leftwich answered 26/10, 2009 at 19:58 Comment(4)
Amusingly, the Windows Team used this flag in a sample on their blog back in April! windowsteamblog.com/blogs/developers/archive/2009/04/16/…Presumable
And a comment from kazoobrewer telling them it no longer works. I guess that would be you then...Presumable
Sometimes it feels like you're the only developer using an API in the wild...Leftwich
Archive of Windows 7 Developers Blog entry Light Up with Windows 7 LibrariesShantay
B
5

The reason for this can be found in the documentation:

FOS_PICKFOLDERS: Present the Open dialog offering a choice of folders rather than files.

Using FOS_PICKFOLDERS for "save" was never supposed to be supported - but Vista didn't enforce it. Use IFileOpenDialog instead and you're good to go. You are picking an existing folder (not specifying a folder to create), so open was always the correct choice.

Bouncer answered 1/12, 2009 at 6:50 Comment(0)
P
2

I haven't played around with the Windows 7 dialogs yet, but downloaded the Windows® API Code Pack just this morning as I am implementing the Thumbnail Toolbar and Icon Overlay in the application I am working on. It'll probably point you in the right direction.

Presumable answered 26/10, 2009 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.