title: FTP multiple files in C# without reestablishing connection
body: <p>The FTP protocol is designed to support a control channel, and use that control channel to tell the server to open TCP connections and transfer files.</p>
  
  <p>The server sending or receiving files does NOT have to be the same as the server that the FTP control channel is connected to.  It can be a "triangle" type connection.</p>
  
  <p>It also allows the client to log in once on the control channel, and repeatedly tell the server to transfer files, without re-logging into the control channel.</p>
  
  <p>Apparently, this concept has completely escaped MS when they created the C# <code>FtpWebRequest</code> class.</p>
  
  <p>I need to do exactly what the FTP protocol was designed to do:</p>
  
  <ol>
  <li><p>Connect to a server</p></li>
  <li><p>Pass in credentials</p></li>
  <li><p>Create directories (and happily ignore an 'already exists' error)</p></li>
  <li><p>Repeatedly transfer files up to the server</p></li>
  <li><p>Log out of the control channel</p></li>
  </ol>
  
  <p>I sure am not seeing that ability in the <code>FtpWebRequest</code> class.  Or anything that would appear to allow that kind of a flow in C# code.</p>
  
  <p>I have looked:</p>
  
  <ul>
  <li><p>at <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/9e14bc29-25bf-45ec-9303-1d8ffda2064d/c-ftp-send-multiple-files-log-in-only-once?forum=csharpgeneral" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/9e14bc29-25bf-45ec-9303-1d8ffda2064d/c-ftp-send-multiple-files-log-in-only-once?forum=csharpgeneral</a>  </p></li>
  <li><p>and at <a href="https://stackoverflow.com/questions/20323462/upload-multiple-files-to-ftp-in-c-sharp">Upload Multiple files to FTP in c#</a></p></li>
  <li><p>and others.</p></li>
  </ul>
  
  <p>But none of this seems to allow control that way it was meant to be.</p>
  
  <p>I can specify the <code>KeepAlive</code> property, but the loop has to repeatedly call the <code>WebRequest.Create(targetName);</code> function, which would create a NEW connection, and get a NEW response. Then they fall out of scope or are orphaned, so by definition, they are destroyed.  Therefore the connection MUST be closed, and then will have to be reopened.  For a data connection, that's okay, but where is the ability to manipulate the CONTROL port?</p>
  
  <p>The class doesn't allow the user to differentiate from a CONTROL port and a DATA port, as the FTP specification defines.</p>
  
  <p>Is there a ways to use a C# class to do FTP the way it was meant to be?  Because in Microsoft's narrow mindset, the whole world looks like an HTTP Get/Response protocol. </p>
  
  <p>Any advice is appreciated.</p>
  
  <p>-Scotty</p>