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#)
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.
Take a look at this example:
My file is stored in this directory on the source FTP server:
I need to transfer the file myfiletest.csv
to different SFTP server. The path is: SecondServer/placehere
.
Finally, once the file was transferred, I want to move the source file to a folder Process
.
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.
Can help me to solve it?
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).
public void Main()
{
var directory =
new DirectoryInfo(Dts.Variables["User::FolderPath"].Value.ToString());
FileInfo[] files = directory.GetFiles();
DateTime lastModified = DateTime.MinValue;
foreach (FileInfo file in files)
{
if (file.LastWriteTime > lastModified)
{
lastModified = file.LastWriteTime;
Dts.Variables["User::FileName"].Value = file.ToString();
}
}
MessageBox.Show(Dts.Variables["User::FileName"].Value.ToString());
Dts.TaskResult = (int)ScriptResults.Success;
}