Unknown Coder
Unknown Coder

Reputation: 6741

C# modify a config file for a windows service

I have a windows service that reads from a config file. I need to modify this config file prior to the application starting. How can I create a GUI that would handle the changes to the config file. I know that a service does not have a GUI per se, but I really just need something to modify some strings in the config file and then start the service.

Upvotes: 2

Views: 2192

Answers (1)

Sky Sanders
Sky Sanders

Reputation: 37104

You can open the configuration and manipulate it programatically...

Configuration cfg = ConfigurationManager.OpenExeConfiguration("your path here");
// perform unspeakable acts upon cfg using your GUI
cfg.Save();

Update to elaborate on comments:

Generally when I need to provide a UI for a service, I expose a wcf channel using a net.tcp endpoint, which does not require special priveledges, and write a simple tray icon app to talk to it. Quick and easy compared to previous strategies.

Upvotes: 4

Related Questions