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 417821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:37:04+00:00 2026-05-12T18:37:04+00:00

I am writing a small command-line tool for my own daily tasks, and having

  • 0

I am writing a small command-line tool for my own daily tasks, and having problems reading from a XML file I have used for configuration. As per the examples, I use this code to load the XML file for Linq-to-XML.

    XDocument doc = XDocument.Load("SearchSources.xml");

What I’m having problems with is when I “deploy” my app and XML to c:\windows\system32 for easy access, it won’t work when I try to launch the file from the RUN prompt (e.g. run => TOOL -commands) because it’s looking for the XML relative to wherever I launch the application.

I could obviously change the path to be the full path, e.g. c:\windows\system32\SearchSources.xml in the code, but that would prevent me from running it via F5 in Visual Studio.

EDIT: I am attempting to do this in code, rather than modifying configuration files when I deploy the app to other locations.

  • 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-05-12T18:37:05+00:00Added an answer on May 12, 2026 at 6:37 pm

    Use:

    String filePath = System.IO.Path.GetDirectoryName(
        System.Reflection.Assembly.GetExecutingAssembly().Location
    ) + @"\SearchSources.xml";
    

    That will create a path to the file based on the directory of the executable.

    Or using Path.Combine, as suggested:

    String filePath = System.IO.Path.Combine(
        System.IO.Path.GetDirectoryName(
             System.Reflection.Assembly.GetExecutingAssembly().Location
        ),
        "SearchSources.xml"
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing a small command line tool, it would be nice to output in different
I'm writing a small Ruby command-line application that uses fileutils from the standard library
I have been learning C++ in school to create small command-line programs. However, I
I'm writing a small tool in C# which will need to send and receive
I have been writing a small application using C# to copy a document into
I'm writing a small file conversion utility. Files get automatically converted when they are
Here is the problem... I'm writing very small plugin for Blender, I have 10
I have been writing a small web application in C# .NET4.0 to try and
I have created a small program which logs text data to a file on
I am currently writing a small calendar in ASP.Net C#. Currently to produce the

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.