title: Transferring file between two remote FTP and SFTP servers in SSIS/C# and archiving source files to another directory afterwards
body: <p>I've been struggling with this for a while and I do not really understand how to solve this situation by using SSIS (I was thinking about creating a Script task in C#)</p>
  <p>This is my problem: everyday a file is created and stored in a certain
  directory in a specific server (I can access it by using a FTP
  protocol within a client-server application such as FileZilla or any
  other program). I want to transfer that file to a different server that uses SFTP protocol. And then, once it has been successfully placed in that server move the original file to a different folder on the source FTP server.</p>
  <p>Take a look at this example:</p>
  <p>My file is stored in this directory on the source FTP server:
  <a href="https://i.stack.imgur.com/5tcQC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5tcQC.png" alt="enter image description here" /></a></p>
  <p>I need to transfer the file <code>myfiletest.csv</code> to different SFTP server. The path is: <code>SecondServer/placehere</code>.</p>
  <p><a href="https://i.stack.imgur.com/W4zik.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W4zik.jpg" alt="image" /></a></p>
  <p>Finally, once the file was transferred, I want to move the source file to a folder <code>Process</code>.</p>
  <p><a href="https://i.stack.imgur.com/sCFbD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sCFbD.jpg" alt="enter image description here" /></a></p>
  <hr />
  <p>Been trying to copy and move the file from the first server to the second one without success and I'm kinda lost right now.</p>
  <p>Can help me to solve it?</p>
  <hr />
  <p>This is how I'm trying to read the files from the FTP server (i've not managed to read it properly or even save it in my local environment).</p>
  <pre><code> public void Main()
   {
      var directory =
          new DirectoryInfo(Dts.Variables[&quot;User::FolderPath&quot;].Value.ToString());
  
      FileInfo[] files = directory.GetFiles();
      DateTime lastModified = DateTime.MinValue;
  
      foreach (FileInfo file in files)
      {
          if (file.LastWriteTime &gt; lastModified)
          {
              lastModified = file.LastWriteTime;
              Dts.Variables[&quot;User::FileName&quot;].Value = file.ToString();
          }
      }
  
       MessageBox.Show(Dts.Variables[&quot;User::FileName&quot;].Value.ToString());
  
  
       Dts.TaskResult = (int)ScriptResults.Success;
   }
  </code></pre>