I am using the FolderBrowserDialog in a Powershellscript.
Is it possible to remember the selected folder and use it next time as starting location for browsing folders? Now it starts everytime in the same folder (regardless if I use RootFolder and/or SelectedPath)
It is hard to give an intelligent and helpul advice if you do not show some of the code you’re using. But anyway you can save any location in a variable and use it later on if you need.
The code is part of an addin (called DataStandard) for Autodesk Inventor (3D CAD software) and Vault (Datamanagement software). With this addin a dialog pops up when saving a file for the first time. See this Example.
This DataStandard exists of several XAML files for the dialogs and ps1 files for the logic.
In the XMLfile I have made a button for selecting a folder for saving the file. This button points to a simple ps1 file for showing the FolderDialog. This ps1 file has this code:
Buteverytime I use this DataStandard dialog, the folder dialog starts at the same folder. I have tried with and without the Rootfolder and SelectedPath lines.
Even if it is more or less the same code, I tried your code in my case, but it still returns to the preselected location everytime the folderbrowser dialog starts. Maybe this is happening, because everytime I am openeing the folderbrowser, the addin/schript is started again, so it starts as if it is started for the first time?
I mean, the script is not a constantly running programm, but is used by the addin in the CAD software (and does not “live” inside this CAD programm), and it will be started as a new instance of the script? I don’t know how I can explain it clearly…
Maybe I have to do it in some kind of dirty way by storing the last used path in a txt file.
That’s what I meant in my first answer. You will have to find a way to determine the folder you want to start the forlder browser dialog in. That should happen outside of the function. Then you can use my code example and run the folder browser dialog with the starting folder you like by calling the function with the folder you want provided as parameter.