What is Configuration Data? How is it related to Configuration Files? How is it related to Application Settings? When do you use it?

  • Thread starter Thread starter Minh T
  • Start date Start date
M

Minh T

Guest
I'm new to writing programs that use information provided at runtime. I've come across use cases where I'd like my application to read from a file to know what to do instead of prompting for user input.

For example, a C# application that takes data from a specific directory and processes it (where the C# application does other things like continually monitors the data files in that directory for changes, inserts the data into a database, or runs computation against them -- in essence that program needs to run for a long period of time). Now, that application should perform its duties given any system path to the directory containing the data files and let's say the path doesn't change often (say once every month, when the user wants the program to perform its duties on a different directory).

One option is to have that C# program periodically read from and parse a plain-text file containing the directory to be examined. The plain-text file might contain a line that looks like this:


Data Directory: C:\Users\Alice\Data\TemperatureSensor
Operation: RunningSum
User Name: Alice


Alternatively, the C# program can periodically query for the Data Directory to examine, the computation operation to be done, and for the username (blocking all other functionality such as database insertions, etc...) until the user steps in to provide that information. This is undesirable in my use-case.

Is there a C# library that manages program access of such plain-text files, does the parsing for me, and updates the application variables (e.g., the string variable that stores where the C# application should look for data) as soon as it is changed by the user (so the plain-text file is human-readable, the user can change field values to affect the program behavior)?

I believe such plain-text files are called Configuration files but I'm hesitant to use that term since it could mean something else/be called something else in the .NET framework. Should I look at the System.Configuration API?

Continue reading...
 
Back
Top