C# Getting a string from one config file to be used by multiple projects

In my project I have a Windows Service and a WCF Service doing some actions on the same folder on a computer. The location of that folder will be given by the user within an app.config file that is included in the Windows Service project.

Now, I want the WCF Service to know the location of that folder (the folder given by the user), without the user having to type it into the WCF Service config file as well.

How would I go about doing that?



There are lots of possibilities here:

  1. Add the path of the Windows Service's config file as a setting in the WCF service's config file, and use that path to read the file with an XML Reader.

  2. Store the folder path in some centralized system, like a database or the registry, and have both services obtain the setting from that centralized placed.

  3. Specify the path in each individual config file, but use a post build event to make sure they stay current. (For instance, maybe the post-build event retrieves the config setting from the DB and then writes it to the config file)

  4. Have one service expose the configuration setting as a public service call. For instance, the WCF service could invoke a method on the Windows service to determine which path to process.

You can place it in the Machine.config, and both the WCF application and the Windows service can access it.


Need Your Help

Insert batch codeigniter

php codeigniter

This is my table on mysql