Resolved Where to put INI file?

Program4Food

Active member
Joined
Nov 22, 2021
Messages
40
Programming Experience
10+
I know, XML is the way and the wave. Im still struggling to even get my XML code working!

In the mean while, I have learned how to R&W and delete entries from INI files, which... for the applications I have in mind at this time, will work just fine!

(Dont fret, I am still trying to learn how to R&W XML!)

My question is, WHERE do I put the INI? I know we typically dont want to put in the the app directory, Id rather put it in the user/data folder?


1) Where do you suggest putting the INI config file? My app will manually generate it, so I will need R&W permissions.

2) What function should I use to find the user's data/config path in which to put the INI file?
(I may have to come back later and get help with the code).


Kind thanks for your time,
Andrew
 
I don't understand why you are struggling with XML configuration files -- unless you are trying to read and parse the XML files yourself instead of using the XmlDocument or XDocument classes to do the reading and parsing for you.

Anyway since your primary concern is loading and saving application settings, these will make things infinitely easier for you because they also take care of settings that go into the readonly app folder as well as the read/write application data folders.


 
Skydiver, awesome man! Thank you!

Ill work some code out and gain famaliarity with the functions you linked..

BTW, if you were going to write a config file (regardless of the type), where would YOU put it?
Maybe why too, so I have insight to your thinking.

Thanks,
Andrew
 
Skydiver, thank you once more for your kind help! I will also be reading up on the two links you posted on XML!

I am self taught, not formal instructed; and I code on the side because I love code, and also I often run into
things I want to do that there is no program for... Anywho, I ended up being herkey jerkey in my learning which
leaves voids like swiss cheese which keep me from mentally connecting the dots and understanding whatever
concept I am trying to learn.

Thanks again friend!
 
For .NET Framework desktop apps, I would use the app.config which basically maps to the settings I mentioned in post #3. For .NET Core apps -- desktop and web, I would store them in appsettings.*.json. For any per user settings for web apps, I would stuff them into a NoSQL database. Same for mobile -- some kind of embedded NoSQL database for storing settings. I can't get a NoSQL database, then I'll likely serialize/deserialize settings to a JSON file.
 
Regarding the app & user settings, I was working with that earlier today!
 

Attachments

  • app and user settings.jpg
    app and user settings.jpg
    197.5 KB · Views: 24
Ill also be looking into NoSQL, just skimmed a google search real quick... Most of my DBs are in fact non-relational so the concept is friendly to me.

I also have the DLL for SQLite3, which is what Ill be starting to work with a little later. It will be a combo project, as I will also embed it into the
compiled EXE by way of resource list, that way the end user will only have 1 file to work with. I want to do some Lite DB in winforms and con.

Andrew
 
Working great so far, I want to populate the text box will all the values still... I need to step away from the keyboard and get some rest.

What I am looking for is insight as to WHERE to put my config file, and why you (whoever chooses to answer) pick that folder.
Also wanted to verify I will have R&W permissions.. Once I have that in my code chest Ill move the thread to resolved.

99% of the apps I write and would be sharing would be in ZIP, just unpack and run the EXE, no install needed (the original
old school portable app)... I presume if there were a config folder made for the app it would be done by the installer,
and the installer would handle making sure the app had R&W permissions.

Thanks so much!
 

Attachments

  • env special fldr.jpg
    env special fldr.jpg
    209.4 KB · Views: 11
If your plan to have users do an XCOPY deployment or a extract Zip file deployment, it would make the most sense to put the .INI file right beside your executable. It would be the location of least surprise -- unless you are *nix head. In that case, it seems that the *nix convention is to either put the settings files in the users home directory, or in a directory named "conf" below the root of the installation directory of the app/binary.
 
I think Skydiver has a good point, if the user extracted the EXE to a folder, it must have RW permissions, so to keep things clustered & easily located it would be smart to gen the INI in the same folder as the app.
 
Back
Top Bottom