Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. a question about config file for windows service program

a question about config file for windows service program

Scheduled Pinned Locked Moved C#
debuggingtutorialquestionworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bright Zhang
    wrote on last edited by
    #1

    i have windows service program,and i want to make a config file for it. if the config file is placed in the directory:system32/,i can access it by System.Environment.SystemDirectory,but when placed in the windows service executable files' directory(bin\debug\),i don't know how to access it.

    A 1 Reply Last reply
    0
    • B Bright Zhang

      i have windows service program,and i want to make a config file for it. if the config file is placed in the directory:system32/,i can access it by System.Environment.SystemDirectory,but when placed in the windows service executable files' directory(bin\debug\),i don't know how to access it.

      A Offline
      A Offline
      Andy Brummer
      wrote on last edited by
      #2

      You don't need to access the file directly. Use the classes in the system.configuration namespace to access the configuration file. If you just have simple string data to access then you can use the AppSettings class and section. Otherwise you can write your own section handler. The file should be named yourexe.exe.config, but vs.net will copy any file named app.config from the root of your project to the output directory and rename it to the proper name so your service will read it.


      I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

      B 1 Reply Last reply
      0
      • A Andy Brummer

        You don't need to access the file directly. Use the classes in the system.configuration namespace to access the configuration file. If you just have simple string data to access then you can use the AppSettings class and section. Otherwise you can write your own section handler. The file should be named yourexe.exe.config, but vs.net will copy any file named app.config from the root of your project to the output directory and rename it to the proper name so your service will read it.


        I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

        B Offline
        B Offline
        Bright Zhang
        wrote on last edited by
        #3

        o,thank you very much.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups