title: Why does my ListDirectory ftp-request throw an exception
body: <p>I have following code:</p>
  
  <pre><code>var listDirectoryFtpRequest = (FtpWebRequest) WebRequest.Create(directoryUri);
  listDirectoryFtpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
  listDirectoryFtpRequest.Credentials = /* my credentials */;
  listDirectoryFtpRequest.KeepAlive = false;
  listDirectoryFtpRequest.UsePassive = true;
  listDirectoryFtpRequest.UseBinary = true;
  
  using (var response = listDirectoryFtpRequest.GetResponse())
  {
      return true;
  }
  </code></pre>
  
  <p>The directory, which is stored in <code>directoryUri</code>, does exist.</p>
  
  <p>I have following log from my ftp-server</p>
  
  <pre><code>(022102) 30.05.2012 08:32:18 - **USER** (213.235.245.89)&gt; 230 Logged on
  (022102) 30.05.2012 08:32:19 - **USER** (213.235.245.89)&gt; OPTS utf8 on
  (022102) 30.05.2012 08:32:19 - **USER** (213.235.245.89)&gt; 200 UTF8 mode enabled
  (022102) 30.05.2012 08:32:20 - **USER** (213.235.245.89)&gt; PWD
  (022102) 30.05.2012 08:32:20 - **USER** (213.235.245.89)&gt; 257 "/" is current directory.
  (022102) 30.05.2012 08:32:21 - **USER** (213.235.245.89)&gt; CWD /21792543/2/
  (022102) 30.05.2012 08:32:21 - **USER** (213.235.245.89)&gt; 250 CWD successful. "/21792543/2" is current directory.
  (022102) 30.05.2012 08:32:22 - **USER** (213.235.245.89)&gt; TYPE I
  (022102) 30.05.2012 08:32:22 - **USER** (213.235.245.89)&gt; 200 Type set to I
  (022102) 30.05.2012 08:32:23 - **USER** (213.235.245.89)&gt; PASV
  (022102) 30.05.2012 08:32:23 - **USER** (213.235.245.89)&gt; 227 Entering Passive Mode (10,40,31,10,229,112)
  (022102) 30.05.2012 08:32:27 - **USER** (213.235.245.89)&gt; NLST
  (022102) 30.05.2012 08:32:27 - **USER** (213.235.245.89)&gt; 150 Connection accepted
  (022102) 30.05.2012 08:32:27 - **USER** (213.235.245.89)&gt; 226 Transfer OK
  (022102) 30.05.2012 08:32:29 - **USER** (213.235.245.89)&gt; disconnected.
  </code></pre>
  
  <p>Nevertheless I get following exception:</p>
  
  <pre><code>System.Net.WebException: The underlying connection was closed: The server committed a protocol violation.
     at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
     at System.Net.FtpWebRequest.RequestCallback(Object obj)
     at System.Net.CommandStream.InvokeRequestCallback(Object obj)
     at System.Net.CommandStream.Abort(Exception e)
     at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
     at System.Net.FtpWebRequest.GetResponse()
     at **MYCLASS**.**MYMETHOD**
  </code></pre>
  
  <p>Why? ... and how can I fix this?</p>
  
  <p>PS.: I've found <a href="https://stackoverflow.com/questions/9815919/the-underlying-connection-was-closed-the-server-committed-a-protocol-violation">another question</a> here on SO with similar symptoms. But do I really have to go for the <code>KeepAlive = true</code>-hack?</p>