title: Delete remote files?
body: <p>I have files that I want to delete. Connection can be from file sharing, http, and ftp.</p>
  
  <p>Example of files to delete:</p>
  
  <pre><code>//mytest//delete//filename.bin
  ftp://mytest/delete/filename.bin
  http://mytest/delete/filename.bin
  </code></pre>
  
  <p>Here's what I did:</p>
  
  <pre><code>Uri target = new Uri(@"ftp://mytest/delete/filename.bin");
  FileInfo fi = new FileInfo(target.AbsoluteUri);
  fi.Delete();
  </code></pre>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>The given paths format is not supported</p>
  </blockquote>
  
  <p>Is there a single code that can delete in all these file types?</p>
  
  <p>I have created a simple code for this task(based on thread response).<br>
  This is the input:</p>
  
  <pre><code>Uri target = new Uri(@"ftp://tabletijam/FileServer/upload.bin");
  Uri target = new Uri(@"http://tabletijam/FileServer/upload.bin");
  Uri target = new Uri(@"\\tabletijam\FileServer\upload.bin");
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>bool DeleteFileOnServer(Uri serverUri)
  {
      if (serverUri.Scheme == Uri.UriSchemeFtp)
      {
          FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
          request.Method = WebRequestMethods.Ftp.DeleteFile;
  
          FtpWebResponse response = (FtpWebResponse)request.GetResponse();
          lblStatus.Content = response.StatusDescription;
  
          response.Close(); 
  
          return true;
      }
      else if (serverUri.Scheme == Uri.UriSchemeFile)
      {
          System.IO.File.Delete(serverUri.LocalPath);
  
          return true;
      }
      else if (serverUri.Scheme == Uri.UriSchemeHttp || serverUri.Scheme == Uri.UriSchemeHttps)
      {
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverUri);
          request.Method = WebRequestMethods.Http.DeleteFile;
  
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
          lblStatus.Content = response.StatusDescription;
  
          response.Close();
  
          return true;
      }
      else
      {
          lblStatus.Content = "Unknown uri scheme.";
          return false;
      }
  }
  </code></pre>
  
  <p><code>Ftp</code> and <code>File</code> deleted successfully. <code>WebRequestMethods.Http</code> does not contain DeleteFile. </p>
  
  <p>So my question is, how do I delete file from this URI?</p>
  
  <pre><code>http://tabletijam/FileServer/upload.bin
  </code></pre>