title: 550 error on retrieving filesize while uploading file
body: <p>I'm trying to get the file size while I'm uploading the file. My end goal is to try and get the upload speed, but in my while loop i get a Exception calling "OpenRead" with "1" argument(s): "The remote server returned an error: (550) File unavailable (e.g., file not found, no access).</p>
  
  <p>Please see code below</p>
  
  <pre><code>$uploadRemoteFile = "Remote URI"
  $ftpuname = "UserName"
  $ftppassword = 'Password'
  
  function upload-ftp{
      $File = "$env:TEMP\something.exe"
      $webclient = New-Object System.Net.WebClient
      $webclient.Credentials = New-Object System.Net.NetworkCredential($ftpuname,$ftppassword); 
      $uri = New-Object System.Uri($uploadRemoteFile)
      $webclient.UploadFileAsync($Uri, $File)
      $arrayftp = @()
      Function Get-newfilesize{
          $webclientRead = New-Object System.Net.WebClient;
          $webclientRead.Credentials = New-Object System.Net.NetworkCredential($ftpuname,$ftppassword); 
          [void]$webclientRead.OpenRead($uri);
          [Int64]$bytes_total= ($webclientRead.ResponseHeaders["Content-Length"])
          $webclientsize = ($bytes_total.ToString());
          $webclientsize
      }
      while ($webclient.IsBusy){
          $oldftpfile = Get-newfilesize;
  
          $oldftpdate = Get-Date;
  
          Start-Sleep -Milliseconds 1
  
          $newftpfile = Get-newfilesize;
          $newftpdate = Get-Date;
  
          $ftpsizediff = $newftpfile - $oldftpfile;
          $ftptimediff = $newftpdate - $oldftpdate;
  
          $totalftpdiff = $ftpsizediff / $ftptimediff.totalseconds;
          $totalftpdiff  | foreach {
              if ($_ -gt 0){$arrayftp += $_ }
          }
      }
      $testftpcap= New-Object psobject -Property @{"Upload Speed" =((($arrayftp | measure -Average).Average/1MB)* 10)}
      $testftpcap | Export-csv -NoTypeInformation -Path $env:TEMP\ftpspeed.csv
  }
  </code></pre>
  
  <p>Thanks</p>