Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8136161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:40:19+00:00 2026-06-06T10:40:19+00:00

I have made a Windows Service that gets installed in a c:\Program Files\My Service

  • 0

I have made a Windows Service that gets installed in a c:\Program Files\My Service directory. Along with the executable, I have an XML file that gets installed in the same directory. This XML file is used by the service to get user defined information.

In the code of the service I read the file as if it were local to the executable.. example:

DataSet ds = new DataSet();
ds.ReadXml("Foo.xml");

However, when I run the service, the service throws an exception saying:

Could not find file ‘C:\Windows\system32\Foo.xml’

Since the executable lives in c:\Program Files\My Service I expected the Windows Service to look for the XML file in c:\Program Files\My Service\Foo.xml. Obviously, that’s not the case.

How can I force the service to look (relatively) for the Foo.xml file in the same location where the service executable lives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:40:24+00:00Added an answer on June 6, 2026 at 10:40 am

    Use this:

    System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Foo.xml");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows service that needs to access the files (sometime modification also)
I have been made a windows service.in which i have been added project installer.in
I have a Windows Service that does the following when started. When running via
I have a Windows Service that overrides the OnStart and OnStop methods to call
I have created windows service. I need to run that automatically after 2 minutes.
I have a windows service, that is occasionally crashing and stopping when an unhandled
I have a program I'm converting to a Windows Service (in C#). This program
i have a windows service that get user details and save the result into
I have a .NET windows service that is calling cdb.exe to analyze crash dumps.
Background : I have a C# Windows Forms application that contains a Windows service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.