Because the program needs a configuration file, the configuration file can be created with VS, and then add the appSettings node, the value of my configuration file contains some special symbols, such as: < > These special symbols, will report an error, and it needs to be escaped to be normal
Decisively don't use this thing, because escaping special strings is too troublesome, and there is another way to make the configuration into a json string, but it's also quite troublesome, half of the program configuration files are ini files, and I found a good third-party component "ini-parser"
.NET, Mono, and Unity3d compatible (*) libraries for reading/writing INI data from IO streams, file streams, and strings written in C#.
Merge operations of complete ini files, parts or even subsets of keys contained in files are also implemented.
The library is 100%. .NET code and does not have any dependencies on Windows API calls for easy portability.
First, the nuget command is installed as follows:
Read and load ini configuration file:
Read the configured value:
Update or add new configurations
It's very easy to use, the ini file of the operation, by default is read and added from the root directory of the program, my code is as follows:
The configuration file format is as follows:
[db_config] SqlType = 123 SqlConn = test
|