title: Powershell - path's format is not supported when variables in the file name
body: <p>I'm trying to add an XML declaration to multiple files in a directory. The code works for a single file with hard-coded name but when I want to run it for multiple files, I'm getting the following error: </p>
  
  <blockquote>
    <p>"Exception calling "Save" with "1" argument(s): "The given path's
    format is not supported."</p>
  </blockquote>
  
  <p>I'm using:</p>
  
  <pre><code>$FilePath = C:\test
  $files = Get-ChildItem $FilePath\*.xml
  foreach ($file in $files)
  {
  $xml = [xml](get-content $file)
  $decl = $xml.CreateXmlDeclaration("1.0", "ucs-2", "yes")
  $xml.InsertBefore($decl, $xml.DocumentElement)
  $xml.save($FilePath$file)
  }
  </code></pre>
  
  <p>I've been changing the last line to </p>
  
  <pre><code>$xml.save($FilePath+"\"+$file)
  $xml.save("$FilePath\$file")
  </code></pre>
  
  <p>and other formats but still getting the same error.</p>