I am a bit late to the party but just for anyone else who faces isssues.
In my application multiple file dialogs are used in various places and for different purposes. So you are likely to be in different folders as a user when saving or loading a file. Hence it was a very bad user experience to always get the last used folder presented on the startup of any Dialog. After a lot of time wasting I finally find the docu on msdn which states it clearly:
Controlling the Default Folder
Almost any folder in the Shell namespace can be used as the default folder for the dialog (the folder presented when the user chooses to
open or save a file). Call IFileDialog::SetDefaultFolder prior to
calling Show to do so. The default folder is the folder in which the
dialog starts the first time a user opens it from your application.
After that, the dialog will open in the last folder a user opened or
the last folder they used to save an item. See State Persistence for
more details."*
State Persistence
Prior to Windows Vista, a state, such as the last visited folder, was saved on a per-process basis. However, that information was used
regardless of the particular action. For example, a video editing
application would present the same folder in the Render As dialog as
it would in the Import Media dialog. In Windows Vista you can be more
specific through the use of GUIDs. To assign a GUID to the dialog,
call iFileDialog::SetClientGuid.
And that was all I needed. SetDefaultFolder for the first time opening for a user + SetClientGuid so that each instance remembers their own location, for each other opening.
IFileOpenDialog* dlg = fileDialog->GetIFileOpenDialog(); // fileDialog == CFileDialog*
if (dlg)
dlg->SetClientGuid({0x6666a009, 0x6251, 0x4132, 0x23, 0xa5, 0xd4, 0x6, 0x69, 0xc2, 0x89, 0xf});
//new GUID for each different Dialog
This means OP could try to create and assign a new GUID on each opening to make sure that the initial DIR is always used. This feels more like a workaround though, but I wanted to point out the connection of the GUID and the initial DIR with my answer. For my purpose, seperating each different Dialog by a single GUID was enough. If the user really navigates somewhere else for a certain action then they probably know what they are doing and will end up in their folder of choice again on the next opening for the same action(dialog).