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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:51:44+00:00 2026-06-14T21:51:44+00:00

I have a situation where I am running a unit test and trying to

  • 0

I have a situation where I am running a unit test and trying to get the project base path and it is giving me a odd output.

D:\VSCode\Bob.Smith\Projects\MySolution\DEVELOPMENT\MyClasses\MyProject\TestResults\Jacob.Freeman_P1004 2012-11-26 09_21_33\Out

Is this a known issue with VS or just something that I have missed out? I am using the following line with no other code to get the directory information.

string output = null;
output = Environment.CurrentDirectory;

I have tried different various ways to get the directory information such as the following, but it still gives me the same output.

output = System.IO.Directory.GetCurrentDirectory()

Thanks in advance.

  • 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-14T21:51:45+00:00Added an answer on June 14, 2026 at 9:51 pm

    As documentation states Environment.CurrentDirectory:

    Gets or sets the fully qualified path of the current working directory.

    The current working directory is not necessarily the projects base path – It is when you start an exe. While running test this path is set by test runner. This variable can change while program is running.

    In application you should use Assembly.GetEntryAssembly().Location to get location of you exe file. This will not work for tests as they are executed by test runner.

    If for test purposes you simply need location of tested dll file you can use typeof(SomeTypeThatIsDeclaredInThatDLL).Assembly.Location.

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

Sidebar

Related Questions

I have a bit of a special situation. Basically I have a unit test,
I have situation, where running a query that filters by an indexed column in
I have a situation where user requests to do a long running process. I
I have a situation where i need to send commands to a running java
Here is the situation: You have one long-running calculation running in a background thread.
i have situation like this: class IData { virtual void get() = 0; virtual
I have this situation - PhoneGap app running in Android. It uses external API
I'm running SQL Server 2000. I have a situation where users are timing out.
I have this situation: application server running on example.com - this is where html
I have a situation where I might have multiple instances of a program running

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.