Reputation: 4033
I am writing an application using C# and I would like to read some parameters from an external file like for example a text file. The parameters will be saved in the file in the form of
parA = 5
parB = hello
etc
Can you pleas suggest a way how I can do this?
Upvotes: 5
Views: 9824
Reputation: 8730
I know its not what you specifically asked, but if you have the choice I would go with an XML Application config.
There's plenty of resources on it but here's a fairly straight forward example:
Upvotes: 1
Reputation: 1039248
var settings =
from line in File.ReadAllLines("params.txt")
let parameters = line.Split('=')
select new KeyValuePair<string, string>(parameters[0], parameters[1]);
Upvotes: 8