title: How to use FileInfo object from Powershell
body: <p>I am now starting to use PowerShell and after a lot of time using the Unix shells and want to know how to check for the existence of a file or directory.</p>
  
  <p>In Powershell why does <code>Exist</code> return false in the following expression?</p>
  
  <pre><code>PS H:\&gt; ([System.IO.FileInfo]"C:\").Exists
  False
  </code></pre>
  
  <p>And is there a better way to check if a file is a directory than:</p>
  
  <pre><code>PS H:\&gt; ([System.IO.FileInfo]"C:\").Mode.StartsWith("d")
  True
  </code></pre>