title: Check if directory exists on FTP server
body: <p>I'm running a check to see if a directory exists on my FTP server:</p>
  
  <pre><code>    public bool DirectoryExists(string directory)
      {
          bool directoryExists;
  
          var request = (FtpWebRequest)WebRequest.Create(directory);
          request.Method = WebRequestMethods.Ftp.ListDirectory;
          request.Credentials = new NetworkCredential("user", "pass");
  
          try
          {
              using (request.GetResponse())
              {
                  directoryExists = true;
              }
          }
          catch (WebException)
          {
              directoryExists = false;
          }
  
          return directoryExists;
      }
  </code></pre>
  
  <p>In this case:</p>
  
  <pre><code>directory = @"ftp://ftp.example.com/Rubicon";
  </code></pre>
  
  <p>On my server, I have a folder named <code>Rubicon1</code>.  This is causing my check to return <code>true</code>. How can I ensure that it fails unless it matches the directory name exactly?  </p>