Solved

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

Posted on 2010-11-24
2
324 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Memory Usage 2 50
Icons and Colors for Terms 3 24
Stream.BeginRead and Stream.EndRead in .NET Core 5 37
Anyway to make "All" the default in the dropdown? 6 34
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

22 Experts available now in Live!

Get 1:1 Help Now