06-28-2019 09:28 AM
The default directory in FileSelectPopup is defined as:
int FileSelectPopup (char defaultDirectory[], …)
defaultDirectory[] : If you enter "", the function uses the current working directory for the initial directory. If the user selects a directory, and the popup is displayed again in the application, the default directory is the user-selected directory.
This behavior creates a problem for my application. I need the default directory to always be the one that I specify in the defaultDirectory[], not the one that user selected previously. Is there a way to override the user selected directory and always start the browsing in the specified directory?
Solved! Go to Solution.
06-28-2019 10:22 AM
If you actually pass a folder pathname in the parameter the function should always start in that folder, isn't it so?
06-28-2019 11:22 AM
And I think there is a parameter so that you can restrict the directory change of the user. So user is stuck with the directory that you specify.
06-28-2019 01:46 PM
No, I'm seeing a different behavior. I do specify the default directory and I tried to restrict the directory change of this specific instance of FileSelectPopup (this instance is for saving config files that are stored in config directory). But I also have another instance of FileSelectPopup to save data files in the data directory. And whenever I call the FileSelectPopup to store the data file in data directory then next time I call the FileSelectPopup to store the config it starts again in the data directory. So restricting the directory change actually makes it worse because I cannot even change the directory to point to the config directory. If I do not restrict the change I can of course always manually change the directory to config, it's not a big problem, but it's just going to be annoying for the users.
Here is an example of the code line that I use (without directory change restriction)
FileSelectPopup (".\\settings", "config.cfg", "*.cfg", "Select file to save settings", VAL_SAVE_BUTTON, 0, 1, 1, 1, pathName);
Am I missing something?
07-01-2019 04:18 AM
I actually see the opposite: the call with no path inherits the path passed to the other call, while the call with a relative (or absolute) path always starts in the proper folder.
See the attached example.
07-01-2019 08:33 PM
Roberto, thanks for your code but I am still seeing the same behavior that I described even with your code. In your example if I copy the Panel.uir to another directory and then select it with either "no path" or "relative path" button then when I press the "relative path" button again it starts in that other directory, not in the \Data directory.
Could it be something wrong with my computer?
07-02-2019 05:25 AM
Now that's weird! I don't understand what can be happening.
What happens if you pass an absolute pathname? I mean something like that:
GetProjectDir (pathName); MakePathname (pathName, "settings", pathName); FileSelectPopup (pathName, "config.cfg", "*.cfg", "Select file to save settings", VAL_SAVE_BUTTON, 0, 1, 1, 1, pathName);
This is more or less the same as your relative path approach but with a fully qualified pathname passed to the function instead.
07-02-2019 07:31 PM - edited 07-02-2019 08:08 PM
Yes, the absolute path works fine and always starts from ...\Data:
r = FileSelectPopup ("C:\\Users\\evi75\\Documents\\misc\\FilePaths\\Data", "*.UIR", "User Interface Resources (*.UIR)", "Select a file", VAL_SELECT_BUTTON, 0, 0, 1, 0, file);
But the relative path still does not and starts from the last browsed directory:
FileSelectPopup (".\\Data", "*.UIR", "User Interface Resources (*.UIR)", "Select a file", VAL_SELECT_BUTTON, 0, 0, 1, 0, file);
I guess I can try to create a string with an absolute path by concatenating the proj directory and the relative path. Is there a function to get the proj directory?
07-02-2019 08:56 PM - edited 07-02-2019 08:56 PM
OK, I found it: GetProjectDir (char directoryName[]);
So this workaround works fine now, thanks for the help!
char directoryName[250];
GetProjectDir(directoryName);
strcat(directoryName, ".\\Data");
r = FileSelectPopup (directoryName, "*.UIR", "User Interface Resources (*.UIR)", "Select a file", VAL_SELECT_BUTTON, 0, 0, 1, 0, file);
07-03-2019 09:33 AM
I've seen the same issue as @eno7538 some weeks ago and I wonder if the behavior depends on the CVI version.
Which version have @eno7538 and @RobertoBozzolo been using?