I use a simple text file scheme picked up over 25 years ago where you put a code at the beginning of every important data line in the text file. Your SavePrefs routine knows how to code each line and your GetPrefs routine knows how to recognize each coded line. All non coded lines in the text file are ignored.
Usually two letters are enough characters for the code. Sometime three are needed. I follow the code with a colon. For example "FP1:" might be the code for "Family Path 1". The line in the text file would look something like, "FP1:X:\\thispath\\whatever\\". The GetPrefs routine just parses each line looking for the code signatures in the first four (in this example) characters of each line. When found it just strips off the first four characters to collect the information. You can have multiple instances for the same data code for some type of information you want to save, like a list, which the GetPrefs adds to a list.
One beauty to the scheme is that the text file is perfectly human readable. You can have whatever comments, instructions and so on in the file for someone to see that your app does not see because those lines do not start with a code. Another advantage is that you can edit that text file outside of the app for testing and fixing purposes. Even back in the day these files were read and written instantly. The SavePref and GetPref routines are so simple to copy for each new project.
I usually end these files with ".dat". An example might look like this:
- This data file whatever.dat is used by AppSuchAndSuch
-
- whatever you want to say
FP1:X:\\thispath\\whatever\\
FP1:X:\\other\\another
FN:12
U1:True
U2:False
The concept works for other applications. It works to communicate between a device and a computer via a serial port. I plan to use it to communicate between a custom Revit command and a separate windows form application. The ".dat" file will be a semaphore file.