Solved

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

Posted on 2010-11-24
2
322 Views
Last Modified: 2012-05-10
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
Comment
Question by:Mackey_man
2 Comments
 
LVL 5

Accepted Solution

by:
buraksarica earned 500 total points
ID: 34206304
try AppDomain.CurrentDomain.SetupInformation.ApplicationBase
0
 

Author Comment

by:Mackey_man
ID: 34206421
Thanks a lot !
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now