Where are configuration files typically stored - both during development and in production?
What are configuration files typically called? What is their extension typically?
I see all the nodes here but do not see any best practices or set ups people typically use. Yes, I have searched. 🙂
I'd like to develop my app using a configuration scheme that others could find if "I get hit by a bus (or covid)".
such configuration files are also called INI files, because of the default "ini" filesuffix.
Usually they are stored next to the executable (like LabVIEW.exe next to LabVIEW.ini) - or in any other place of your choice…
There are actually no universally valid rules but some recommendations.
Storing configuration files next to the exe file used to be a common practice before 2005 or so but got discouraged since Windows XP and on other platforms as well since the location exe files are installed should not be modifiable by normal users for security reasons.
Instead a common practice is nowadays:
1) <ProgramFiles>\<company Name>\<application name>\<configuration name>.ini for configurations that should apply to all users on the machine for this appliacation.
2) Users\<user name>\AppData\Local or Roaming\\<company Name>\<application name>\<configuration name>.ini for configurations that should apply for a specific user.
<ProgramFiles> and Users\<user name>\AppData are both hidden directories and can be reconfigured by a system administrator to point elsewhere so you should use the according "Get System Directory.vi" in the File IO Constants palette to get the respective User or System Preference path and from there built your application specific path, not forgetting to also pass the parent path of your configuration file through a Create Directory node to make sure the directory hierarchy exists before trying to access the configuration file in there.
Really helpful @rolfk. Thanks!
I am sure it would also be good practice to be sure that any configurations being saved have default values assigned if the file does not exist upon first time running the app. I do see that the Open Config File node has a "Create file if not exists" terminal.
Yes, the "create file if not exist" I set to true when wanting to write the configuration. On reading I connect a value to the default input of the Read Config file VIs so it gets a defined value if the value doesn't yet exist in the ini file.