1

I have 3 variable that contains the path of the file, each file is in different folder but the same ftp server:

The first variablecalled file1 contain that value /ds/product/Jan/09122016_product.csv

The second variablecalled file2 contain that value /ds/subproduct/Jan/09122016_subproduct.csv

The third variablecalled file3 contain that value /ds/category/Jan/09122016_category.csv

What i want is to check if the 3 files exists in the ftp in one code.

Actually i can verify only one file in one script task in my case if i want to check the 3 files i need 3 script task but i want to optimize this how can i do that ?

string[] folderArray, fileArray;
ConnectionManager cm = Dts.Connections["FTP"];
FtpClientConnection ftpClient = new  FtpClientConnection(cm.AcquireConnection(null));
ftpClient.Connect();
ftpClient.SetWorkingDirectory("/ds/product/Jan/");
ftpClient.GetListing(out folderArray, out fileArray);

foreach (String file in fileArray)
{
    if (file.Equals("09122016_product.csv"))
    {

    }
}
user2460074
  • 1,252
  • 3
  • 11
  • 28

1 Answers1

0

I'd check the timestamp of the files you're polling using FTP MDTM, but this isn't supported by FtpClientConnection.

Is using System.Net.FtpWebRequest an option? This class supports MDTM with the WebRequestMethods.Ftp.GetDateTimestamp method. It's a bit unclear to me how the FTP control connection lifecycle is handled by this class (it's kept open by default), so I'd test that before deploying to production if the script is heavily used.

See this SO question for a code example: System.Net.FtpWebRequest GetDateTimestamp example

Community
  • 1
  • 1
EventHorizon
  • 2,916
  • 22
  • 30