title: How do Environment.CurrentDirectory work?
body: <pre class="lang-cs prettyprint-override"><code>static void Main(string[] args)
  {
      Console.WriteLine(Environment.CurrentDirectory);
  
      Console.ReadLine();
  }
  </code></pre>
  <p>The code is very simple, but accidentally it raised a question.
  If I press the &quot;Run&quot; button, I will get the output like:</p>
  <pre><code>C:\Users\Admin\source\repos\FeaturesTest\ConsoleApp1\bin\Debug
  </code></pre>
  <p>But if I invoke this program with cmd.exe or Powershell, the output will be the current directory of the console:</p>
  <pre><code>Example 1:
  PS C:\Users\Admin&gt; C:\Users\Admin\source\repos\FeaturesTest\ConsoleApp1\bin\Debug\ConsoleApp1.exe
  C:\Users\Admin
  
  PS C:\Users\Admin&gt; _
  
  Example 2:
  PS C:\Users\Admin\Desktop&gt; C:\Users\Admin\source\repos\FeaturesTest\ConsoleApp1\bin\Debug\ConsoleApp1.exe
  C:\Users\Admin\Desktop
  
  PS C:\Users\Admin\Desktop&gt; _
  </code></pre>
  <p>If I invoke this program with another, the output will be the working directory of the latter (which invoke the former):</p>
  <pre class="lang-cs prettyprint-override"><code>The code of ConsoleApp2 (the caller):
  
          static void Main(string[] args)
          {
              Process.Start(@&quot;C:\Users\Admin\source\repos\FeaturesTest\ConsoleApp1\bin\Debug\ConsoleApp1.exe&quot;);
          }
  </code></pre>
  <pre><code>The output of ConsoleApp1 (the called program, because ConsoleApp2 don't have output):
  
          C:\Users\Admin\source\repos\FeaturesTest\ConsoleApp2\bin\Debug
  
  </code></pre>
  <p>So, I repeat the question: How do Environment.CurrentDirectory work? I just want to know it.<br />
  Thank you.</p>