简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM