✅ How can I save a single string when my program closes?
In my program I've got a file browser, and I'd like to make it so when you open the file dialogue it starts at the previously selected path. In my testing it's been quite annoying having to go to the same path over and over again.
The only method of saving the path that I can think of is writing it to a text file, but that sounds like a bit of a waste just for a single string. Have I got any other options?
6 Replies
Settings like that are usually saved in some sort of a file, no matter how large or small the settings are
Just place it somewhere "invisible" to the user like AppData or some such
You could also use the windows registry
Specifically something like AppData/Roaming/YourAppName @MTMB
Look up Roaming using ApplicationData here https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=net-9.0
Environment.SpecialFolder Enum (System)
Specifies enumerated Constant Special Item ID List (CSIDL) values used to retrieve directory paths to system special folders.
Environment.GetFolderPath Method (System)
Gets the path to the system special folder that is identified by the specified enumeration.
Yeah this is what I had in mind
Thanks guys