[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

How do I read an .ini-file with a Win service on Windows7

I have installed my Service and the .exe-file is located in C:\Program Files (x86)\MyService. I want to read some values from a .ini-file that also should be located in the same folder.

I have previously used the following code to  read file in the same folder as the service exe-file : path = Environment.CurrentDirectory + "\\Mysettings.ini";

When I debug the service I can see that Mysettings.ini must be located in c:\windows\syswow64 to get it to work. What other code than  Environment.CurrentDirectory should I use to get the right path ?
0
Mackey_man
Asked:
Mackey_man
1 Solution
 
buraksaricaCommented:
try AppDomain.CurrentDomain.SetupInformation.ApplicationBase
0
 
Mackey_manAuthor Commented:
Thanks a lot !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now