I found application that use .txt files as config files.
The Files looks like
[[plugin.save]]=[[Save]]
how do I use it in C#?
how can I read The file to my application to use Values in [] as config?
You have to read it as a regular file. Reading it use Dictionary to store values. Example code:
Dictionary<string, string> configuration = new Dictionary<string, string>();
Regex r = new Regex(@"\[\[(\w+)\]\]=\[\[(\w+)\]\]");
string[] configArray = {"[[param1]]=[[Value1]]", "[[param2]]=[[Value2]]"};// File.ReadAllLines("some.txt");
foreach (string config in configArray)
{
Match m = r.Match(config);
configuration.Add(m.Groups[1].Value, m.Groups[2].Value);
}
Please note to check for possible null values. Note also that regex expression should be different if config values can contain for example spaces.
Just use:
var config = File.ReadAllLines(FileLocation)
And then parse it with the
String.Split()
Might use regex as well.
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