In the past I would just create a text file with key value pairs for example WIDTH=40 and manually parse the file. This is getting a little cumbersome is there a standard way to do this preferably with inbuilt support from Visual Studio or the .NET framework.
Configuration files are one of the built-in templates. Right-click on your project, choose Add->New Item. In the template box, select configuration file.
You could to create an Application Configuration File in Visual Studio. It's basically and XML file which you can to use to save your application configuration data, but it's not meant to be read as an XML file: .net framework provides some classes to interact with it.
This link can provide some background and sample code: Using Application Configuration Files in .NET
You could to place this code inside your .config
file:
<configuration>
<appSettings>
<add key="SomeData" value="Hello World!" />
</appSettings>
</configuration>
And you can read it this way in C# (requires a reference to System.Configuration assembly):
Console.WriteLine(
"Your config data: {0}",
ConfigurationManager.AppSettings["SomeData"]);
Note you'll need to escape your data ti fit into a XML file; for instance, a &
character would became &
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