title: Why when trying to delete a file from my ftp server i'm getting exception?
body: <p>This is how i select the file to be deleted from a treeView1:
  I make right click on a file in the treeView in the menu options select "Delete"
  Then calling the delete method.</p>
  
  <pre><code>private void menuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
          {
              if (e.ClickedItem.Text == "Delete")
              {
                  delete(treeView1.SelectedNode.FullPath);
              }
          }
  </code></pre>
  
  <p>This is the method to delete the file:</p>
  
  <pre><code>public void delete(string deleteFile)
          {
              try
              {               
                  FtpWebRequest ftpRequest;
                  FtpWebResponse ftpResponse;
                  string url = "ftp://" + txtHost.Text + "/" + deleteFile;
                  url = url.Replace('\\', '/');
                  Uri serverUri = new Uri(url);
                  ftpRequest = (FtpWebRequest)WebRequest.Create(serverUri);// + "/" + deleteFile);
                  ftpRequest.Credentials = new NetworkCredential(UserName, Password);
                  ftpRequest.UseBinary = true;
                  ftpRequest.UsePassive = true;
                  ftpRequest.KeepAlive = true;
                  ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile;
                  ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
                  ftpResponse.Close();
                  ftpRequest = null;
              }
              catch (Exception ex) { Console.WriteLine(ex.ToString()); }
              return;
          }
  </code></pre>
  
  <p>The path of the file to delete since it's a treeView in the variable deleteFile look like this:</p>
  
  <p>root\B\a-new-beginning.jpg</p>
  
  <p>So i'm using the replace: url = url.Replace('\', '/');
  In the end in serverUri i see: <a href="ftp://ftp.newsxpressmedia.com/root/B/a-new-beginning.jpg" rel="nofollow noreferrer">ftp://ftp.newsxpressmedia.com/root/B/a-new-beginning.jpg</a></p>
  
  <p>This is the right format same for uploading a file.
  But then i'm getting exception on this line:</p>
  
  <pre><code>ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
  </code></pre>
  
  <p>Webexception:</p>
  
  <p>The remote server returned an error: (550) File unavailable (e.g., file not found, no access).</p>
  
  <pre><code>System.Net.WebException was caught
    HResult=-2146233079
    Message=The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
    Source=System
    StackTrace:
         at System.Net.FtpWebRequest.CheckError()
         at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
         at System.IO.Stream.Close()
         at System.Net.ConnectionPool.Destroy(PooledStream pooledStream)
         at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse)
         at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
         at System.Net.FtpWebRequest.GetResponse()
         at FTP_ProgressBar.Form1.delete(String deleteFile) in c:\ftp_progressbar\FTP_ProgressBar\Form1.cs:line 665
    InnerException:
  </code></pre>
  
  <p>Line 665 is:</p>
  
  <pre><code>ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
  </code></pre>
  
  <p>Maybe something with the Replace is wrong ?</p>
  
  <p>This is a screenshot of my ftp server file manager at ipage.com my host.</p>
  
  <p><img src="https://i.stack.imgur.com/qu2Mr.jpg" alt="MyFtpServer"></p>
  
  <pre><code>System.Net.WebException was caught
    HResult=-2146233079
    Message=The underlying connection was closed: An unexpected error occurred on a receive.
    Source=System
    StackTrace:
         at System.Net.FtpWebRequest.CheckError()
         at System.Net.FtpWebRequest.GetResponse()
         at FTP_ProgressBar.Form1.delete(String deleteFile) in c:\ftp_progressbar\FTP_ProgressBar\Form1.cs:line 656
    InnerException:
  </code></pre>