Configuration file handling is a common problem so I wondered why nobody has asked a similar question yet. In .NET we usually use the app.config file for application runtime paramaters, however this seems oversized for some smaller tools. I have considered an .ini
style configuration file.
Are there any other appropriate alternatives which could be easily integrated in any project?
Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there.
A configuration file, often shortened to config file, defines the parameters, options, settings and preferences applied to operating systems (OSes), infrastructure devices and applications in an IT context.
It's polite to put your config files not only in "Application Data" but also in a subfolder just for your software. (The application name, or your company name, etc.) TCHAR szAppData[MAX_PATH]; …
User settings are saved in a file within a subfolder of the user's local hidden application data folder.
For desktop applications you could use application settings. And a similar post illustrating them.
The best practice would be using an app.config file since support for reading it is built right into the .Net framework. I'm not sure why you think it is more oversized than other options like an ini file, at it's most basic an app.config only needs to look something like this:
<configuration>
<appSettings>
<add key="SomeSetting" value="foo" />
</appSettings>
</configuration>
I would not use an own solution if you intend others to use your project. Will you always be the only developer? .NET developers are used with the existing config files.
If <appSettings>
is not enough for you it's easy to create custom config sections. You can either use a visual tool like Configuration Section Designer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With