title: In PowerShell why does "casting" to FileInfo set the wrong FullName, Directory, and DirectoryName
body: <p>I'm noticing a VERY odd behavior in both my PS ISE and PS when I'm getting a <code>FileInfo</code> object by calling</p>
  
  <pre><code>$FileInfo = [System.IO.FileInfo](".\SomeFile.ext")
  </code></pre>
  
  <p>When I look at its properties the <code>DirectoryName</code> and its related properties all default to the ORIGINAL path that PS opens in.</p>
  
  <p>Here's a copy from my ISE which launches as an administrator with <code>c:\Windows\System32</code> as the default path</p>
  
  <p>If I run the following code:</p>
  
  <pre><code>$Fileinfo = [System.IO.FileInfo](".\@OpenWithToastLogo.png")  
  cd c:\temp  
  $Fileinfo2 = [System.IO.FileInfo](".\activation.txt")  
  z:  
  $Fileinfo3 = [System.IO.FileInfo](".\7za.exe")  
  $Fileinfo | fl *
  $Fileinfo2 | fl *
  $Fileinfo3 | fl *
  </code></pre>
  
  <p>I get </p>
  
  <blockquote>
    <p>VersionInfo       :<br>
    File              : C:\WINDOWS\system32\@OpenWithToastLogo.png<br>
    InternalName      :<br>
    OriginalFilename  :<br>
    FileVersion       :<br>
    FileDescription   :<br>
    Product           :<br>
    ProductVersion    :<br>
    Debug             : False<br>
    Patched           : False<br>
    PreRelease        : False<br>
    PrivateBuild      : False<br>
    SpecialBuild      : False<br>
    Language          :<br>
    BaseName          : @OpenWithToastLogo<br>
    Target            : {C:\Windows\WinSxS\wow64_microsoft-windows-openwith_31bf3856ad364e35_10.0.10240.16384_none_7f75eaad41c1f239\@OpenWithToastLogo.png,C:\Windows\SysWOW64\@OpenWithToastLogo.png}<br>
    LinkType           : HardLink<br>
    Mode               : -a---l<br>
    Name               : @OpenWithToastLogo.png<br>
    Length             : 160<br>
    DirectoryName      : C:\WINDOWS\system32<br>
    Directory          : C:\WINDOWS\system32<br>
    IsReadOnly         : False<br>
    Exists             : True<br>
    FullName           : C:\WINDOWS\system32\@OpenWithToastLogo.png<br>
    Extension          : .png 
    CreationTime       : 7/10/2015 7:00:32 AM<br>
    CreationTimeUtc    : 7/10/2015 11:00:32 AM<br>
    LastAccessTime     : 7/10/2015 7:00:32 AM<br>
    LastAccessTimeUtc  : 7/10/2015 11:00:32 AM<br>
    LastWriteTime      : 7/10/2015 7:00:32 AM<br>
    LastWriteTimeUtc   : 7/10/2015 11:00:32 AM<br>
    Attributes         : Archive  </p>
    
    <p>VersionInfo       :<br>
    BaseName          : activation 
    Target            :<br>
    LinkType          :<br>
    Mode              : darhsl<br>
    Name              : activation.txt<br>
    Length            :<br>
    DirectoryName     : C:\WINDOWS\system32<br>
    Directory         : C:\WINDOWS\system32<br>
    IsReadOnly        : True<br>
    Exists            : False<br>
    FullName          : C:\WINDOWS\system32\activation.txt<br>
    Extension         : .txt<br>
    CreationTime      : 12/31/1600 7:00:00 PM<br>
    CreationTimeUtc   : 1/1/1601 12:00:00 AM<br>
    LastAccessTime    : 12/31/1600 7:00:00 PM<br>
    LastAccessTimeUtc : 1/1/1601 12:00:00 AM<br>
    LastWriteTime     : 12/31/1600 7:00:00 PM<br>
    LastWriteTimeUtc  : 1/1/1601 12:00:00 AM<br>
    Attributes        : -1</p>
    
    <p>VersionInfo       :<br>
    BaseName          :<br>
    7za Target        :<br>
    LinkType          :<br>
    Mode              : darhsl<br>
    Name              : 7za.exe<br>
    Length            :<br>
    DirectoryName     : C:\WINDOWS\system32<br>
    Directory         : C:\WINDOWS\system32<br>
    IsReadOnly        : True<br>
    Exists            : False<br>
    FullName          : C:\WINDOWS\system32\7za.exe<br>
    Extension         : .exe<br>
    CreationTime      : 12/31/1600 7:00:00 PM<br>
    CreationTimeUtc   : 1/1/1601 12:00:00 AM 
    LastAccessTime    : 12/31/1600 7:00:00 PM<br>
    LastAccessTimeUtc : 1/1/1601 12:00:00 AM<br>
    LastWriteTime     : 12/31/1600 7:00:00 PM<br>
    LastWriteTimeUtc  : 1/1/1601 12:00:00 AM<br>
    Attributes        : -1  </p>
  </blockquote>
  
  <p>With my regular account it defaults to my <code>H:\</code> path so the same test would have <code>H:\</code> as the <code>DirectoryName</code>.</p>
  
  <p>And yes, each of these files ONLY exists in the directory it was relative to.</p>
  
  <p>Has anyone seen this before, and do they know a good fix? Using fully qualified of course works but this is for a script that other technicians might run and we're all pretty used to the idea of using relative pathing with PS.</p>