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

  • Home
  • SEARCH
  • 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 6683353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:48:43+00:00 2026-05-26T04:48:43+00:00

I am running my C# application from D:\App\program.cs. My application needs to execute a

  • 0

I am running my C# application from “D:\App\program.cs”. My application needs to execute a file placed in “C:\Program Files\software\abc.exe”.

How can I set the relative path in my program to execute the “abc.exe”?

  • 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-26T04:48:44+00:00Added an answer on May 26, 2026 at 4:48 am

    To answer the question how to get a path that shows the relative location of pathB from pathA. You can use the Uri class to get the relative path.

    string pathA = @"C:\App\program.cs";
    string pathB = @"C:\program files\software\abc.exe";
    
    System.Uri uriA = new Uri(pathA);
    System.Uri uriB = new Uri(pathB);
    Uri relativeUri = uriA.MakeRelativeUri(uriB);
    string relativeToA = relativeUri.ToString();
    
    Console.WriteLine(relativeToA);
    

    This yields “../program%20files/software/abc.exe” for the relative path.

    I have changed your example from D to C though because you can’t have a relative path for two locations on different drive letters, although the above code still works, just yields the absolute.

    OR if the c# bit is a red herring, and as I now understand you want to run a batch file:

    in batch file put:

    cd c:\program files\software\
    abc.exe
    

    abc.exe will then execute from software folder and not folder of the batch file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get runnig path of my application from app.xaml.cs itself?
I have one .net application which would be installed under program files running in
I am writing to the event log from my Windows Forms application running on
In a Forms application I'm displaying log output from a long running command-line application
I have a website running a basic ASP.NET application that is mostly used from
I have a somewhat-long-running stored procedure being called from a PB application. I want
I need to connect to a MongoDB instance from my EJB3 application, running on
How can I close any Office 2007 running application like Word,Excel,Outlook before installing an
I just got a bug report from someone running an app I wrote under
I wanted to set up remote debugging from Eclipse. Tomcat is running as a

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.