title: powershell wrong results for file length
body: <p>I have a file with length of 309247 bytes as this image:
  <a href="https://i.stack.imgur.com/0tDCX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0tDCX.png" alt="enter image description here"></a></p>
  
  <p>If I run this powershell script: </p>
  
  <pre><code>(Get-Item 'C:\TestFile.082').length
  309247
  </code></pre>
  
  <p>But if run the same script but a <code>$file</code> variable it returns this:</p>
  
  <pre><code>$fpath = Get-Item $file.FullName
  $fpath.length 
  309800
  # or 
  (Get-Item $file.FullName).length
  309800
  # or
  $file.length 
  309800
  </code></pre>
  
  <p><strong>NOTE</strong> $file is a variable into a loop for all files contained in a directory</p>
  
  <p>Why if I'm referencing the same file the results are different?</p>
  
  <p>How can I do to get the real value (309247)?</p>
  
  <p>This is my Full Code</p>
  
  <pre><code>$filesToFtp = Get-Item  $pathToFtp -Exclude "*.PreARM"  
  foreach($file in $filesToFtp)
  {
      $fpath = Get-Item $file.FullName
      $fpath.Length
  
      $FileNode = $oXMLDocumentFiles.CreateElement("element","curtmpremotelxml_files","")
      $nodoXML = "&lt;versionnum&gt;"+$versplain+"&lt;/versionnum&gt;"+
                  "&lt;filename&gt;"+$file.Name.ToUpper()+"&lt;/filename&gt;"+
                  "&lt;filesize&gt;"+$file.length+".00&lt;/filesize&gt;"+
      $FileNode.InnerXml = $nodoXML
      $oXMLDocumentFiles.DocumentElement.AppendChild($FileNode)   
  }
  </code></pre>