C
C#2mo ago
MTMB

✅ 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
Angius
Angius2mo ago
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
ISolutionProvider
You could also use the windows registry
jcotton42
jcotton422mo ago
Specifically something like AppData/Roaming/YourAppName @MTMB
jcotton42
jcotton422mo ago
Environment.SpecialFolder Enum (System)
Specifies enumerated Constant Special Item ID List (CSIDL) values used to retrieve directory paths to system special folders.
jcotton42
jcotton422mo ago
Environment.GetFolderPath Method (System)
Gets the path to the system special folder that is identified by the specified enumeration.
MTMB
MTMBOP2mo ago
Yeah this is what I had in mind Thanks guys

Did you find this page helpful?