News:

Download Pelles C here: http://www.pellesc.se

Main Menu

Working Directory woes

Started by PhilG57, Yesterday at 04:16:44 PM

Previous topic - Next topic

PhilG57

I have a Windows project with multiple versions kept in separate directories.  I edit and update in one directory and when those changes look and test good, I move them to another, separate, directory of more stable code.

In any of those project versions, when I open a file with GetOpenFileName(), the directory shown from which to select a file to open, is the directory last used by Pelles C.  For example, in the GetOpenFileName() dialog, if I change to a different directory and select a file from there, that directory becomes the 'default' location shown by GetOpenFileName() the next time it is called.

So far, so good I think.  What I don't understand is with the opening of a new or different project using the same instance of Pelles C, or especially with a new clean instance of Pelles C, why does the default GetOpenFileName() use what I selected before and not the default directory listed in my project's options. As part of the initialization code, I do execute a GetCurrentDirectory() followed by a SetCurrentDirectory() to no avail.

As always, thanks in advance.

PhilG57

Stack Overflow says the directory last selected by GetOpenFileName is stored in the registry and used the next time GetOpenFileName is called.  This seems to be the case, even though I make a point to reset the working directory to that obtained earlier in my code.  As also suggested there, I added the flag "OFN_NOCHANGEDIR" to the GetOpenFileName call with no change in behavior.

I do think this is a user caused error but have yet to determine where I went wrong.