title: Close/destruct an FtpWebRequest
body: <p>I would like to create a C# function in order to test a connection to an FTP Server.</p>
  
  <p><strong>Here is my function :</strong></p>
  
  <pre><code>        FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create("ftp://" + strHost.Trim());
          requestDir.Credentials = new NetworkCredential(strUser, strPass);
          requestDir.Method = WebRequestMethods.Ftp.ListDirectory;
          try
          {
              WebResponse response = requestDir.GetResponse();
              return "ok";
          }
          catch (Exception ex)
          {
              return ex.Message;
          }
  </code></pre>
  
  <p><strong>My problem is very simple :</strong></p>
  
  <p>I I use a good host ( a good FTP Host), my function return "OK".
  If, after, i use a bad host, it return an exception </p>
  
  <pre><code>ERROR 421 : Service not available. Closing control connection.
  </code></pre>
  
  <p>If, <strong>atfer, it re-test</strong> with the good adresse, i have a new time this exception.</p>
  
  <p>I need to close and re-open my application in order to solve this problem.</p>
  
  <p>I try with :</p>
  
  <pre><code>KeepAlive = true / false and no changes.
  </code></pre>
  
  <p>Anyone could help me please ?</p>
  
  <p>Thanks a lot,</p>
  
  <p>Best regards,</p>
  
  <p>Nixeus</p>