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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:35:25+00:00 2026-05-23T19:35:25+00:00

In my application, after the user logs in I set a few picturebox/button/etc images

  • 0

In my application, after the user logs in I set a few picturebox/button/etc images and do some scaling on them and whatnot. I use relative paths for example:

@".\Images\SomeImage.png"

It works fine when the application is launched directly, but if you try to run it via another application:

Process process = new Process();
process.StartInfo.FileName = networkPath;
process.Start();

It dies and comes up with a file not found error, because it cannot locate the images. It also does this if I try to launch it via the command prompt. The executable is stored on a network drive. Why won’t the relative path work in this situation? I can just go ahead and hard code the full path but that makes me feel dirty… Any thoughts?

  • 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-23T19:35:26+00:00Added an answer on May 23, 2026 at 7:35 pm

    This is because the working directory is different – by default when starting a new process the working directory for the new process is set to the working directory of the existing process (which will in turn probably be the directory that existing application is contained within).

    Normally your application will be run with the working directory as the directory that the executable is contained in – this is the default when creating a new shortcut for example (you can see this in the shortcut properties under the “Start in” field.

    When your application is run from the command prompt or from another application however the working directory is changed and the relative paths are resolved to a completely different directory.

    You can either change the calling application to se the WorkingDirectory property of the new process to the value it expects, however the proper way of fixing this it to modify your application so that it uses absolute paths based on the path to the executable. Assembly.GetExecutingAssembly().Location can be used to get the path to the executable being run and so the following code should do the trick:

    static string GetAbsolutePathFromRelative(string RelativePath)
    {
        string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        string absolutePath = Path.Combine(directory, RelativePath);
        // This final call is to stop paths like "C:\Dir\..\OtherDir\file.txt" being returned
        return Path.GetFullPath(absolutePath);
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Scringo all set up in my application. However after the user logs
I've had some problems with a Django application after I deployed it. I use
I'm designing a question-and-answer Ruby on Rails application. After a user logs in, you
I want to run a little application after a user logs in from fast
I am using facebook PHP SDK. After the user allows my application, facebook redirects
Scenario: User A send application request to user B User B accepts request after
The problem is: my application shows a WebView for a user, and after when
I am building an application in which user logs In, by using username and
Goodday, I got an application where an user logs in, and when the log
I'm working on an AIR application that connects to facebook. After the user connects

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.