Get Remote File list Using FTP's Connection Manager

1,608 views
Skip to first unread message

hemanth mpk

unread,
Oct 8, 2010, 11:35:06 AM10/8/10
to CozyRoc
Hi
We were trying to use SFTP task to get the list of remote file names.
We store these file in Object Variable. I want to check what exactly
is in this object. We iterated this object through a ForEach loop
container and use a script task that executes a MessageBox. This
message box is pointed to the variable collected in ForEachLoop
container.

Can you guide me how can I get the exact list of actual file names
present in the remote folder.

looks like that Object Variable is not storing the names but rather
just : "CozyRoc.SqlServer.SSIS.FtpClientConnection2+FileInfo"

My question is how can I get the exact names of this remote files in
Object variable

Thank you
Hemanth

Ivan Peev

unread,
Oct 8, 2010, 11:48:16 AM10/8/10
to CozyRoc
Hi Hemanth,

You have to cast the object to IFileInfo interface. It is documented
here:

http://www.cozyroc.com/ssis/common-api#IFileInfo

All remote file information is available thru this interface. The full
file name is available in the FullName property.

William Ross

unread,
Nov 18, 2014, 11:13:59 AM11/18/14
to coz...@googlegroups.com, ivan...@cozyroc.com
How might you configure a foreach filename container? Or is this only within a script task?

Thanks.

Ivan Peev

unread,
Nov 18, 2014, 11:18:35 AM11/18/14
to William Ross, coz...@googlegroups.com
Hi Bill,

Why do you need the file name ? Please elaborate what you are trying to accomplish.

William Ross

unread,
Dec 16, 2014, 2:15:42 PM12/16/14
to coz...@googlegroups.com, wounded...@gmail.com
Never mind the file name. How would I grab only files created in the last 15 days?

Thanks.

Ivan Peev

unread,
Dec 16, 2014, 2:53:44 PM12/16/14
to coz...@googlegroups.com, wounded...@gmail.com
Hi Bill,

Try: Modifiedtime > Now.AddDays(-15) 
Message has been deleted

William Ross

unread,
Dec 17, 2014, 9:24:14 AM12/17/14
to coz...@googlegroups.com, wounded...@gmail.com
Can you please provide an example C# script illustrating the use of IFtpClient to retrieve files created in the last 15 days?

Your one liners are useless and there are no examples on the web.

Ivan Peev

unread,
Dec 17, 2014, 5:26:35 PM12/17/14
to coz...@googlegroups.com, wounded...@gmail.com
Bill,

Why do you need to write script? Just setup the Filter below and you get will get the list of files for the past 15 days. 

William Ross

unread,
Dec 18, 2014, 8:08:49 AM12/18/14
to coz...@googlegroups.com, wounded...@gmail.com
The SFTP task does not have a Remote Filter and when I set the LocalFilter to Modifiedtime > Now.AddDays(-15) I get the message:

IdentifierElement: Could not find a field/property/variable with the name 'ModifiedTime".

?

William Ross

unread,
Dec 18, 2014, 8:16:30 AM12/18/14
to coz...@googlegroups.com, wounded...@gmail.com
And by the way, why do I have to justify using one of your allegedly supported features? I want to experiment with the API. Do you not have a single C# example of using IFtpClient?

Ivan Peev

unread,
Dec 18, 2014, 4:53:24 PM12/18/14
to coz...@googlegroups.com, wounded...@gmail.com
Bill,

If you are working with the remote server, ModifiedTime will work fine and yes, you do have RemoteFilter parameter. For the LocalFilter parameter you have to use the members in the FileInfo class. For LocalFilter try:

LastWriteTime > Now.AddDays(-15)

Ivan Peev

unread,
Dec 18, 2014, 4:57:28 PM12/18/14
to coz...@googlegroups.com, wounded...@gmail.com
Bill,

We have plenty of script examples on the public script repository here. For IFtpClient use check here.

Bill Ross

unread,
Dec 18, 2014, 5:34:39 PM12/18/14
to Ivan Peev, coz...@googlegroups.com

Any in C# that use the API?

 

Thanks.

Ivan Peev

unread,
Dec 18, 2014, 5:48:23 PM12/18/14
to Bill Ross, coz...@googlegroups.com
Bill,

We don't have examples in C# because C# is not supported in SSIS 2005. You can easily translate the code into C# . The languages are similar.

William Ross

unread,
Dec 29, 2014, 3:58:00 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
Is the remotefilter supposed to follow any documented syntax?

How do I do a startswith test in the remotefilter? For example, maybe?:

name.startswith("m")||name.startwith("j")

?

Thanks.

Ivan Peev

unread,
Dec 29, 2014, 4:59:52 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
Hi Bill,

The Filter parameter syntax is FLEE. This is also stated on the SFTP Task documentation page here.

William Ross

unread,
Dec 29, 2014, 5:47:08 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
How do I reference the file name? I notice you have LastModified available. Where is the list of properties available? And the FLEE documentation doesn't show "AddDays" as a valid method.

Ivan Peev

unread,
Dec 29, 2014, 9:42:54 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
Bill,

All available properties are also listed on the SFTP Task documentation page. AddDays is a method on the standard .NET DateTime structure.

William Ross

unread,
Dec 29, 2014, 9:47:18 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
And what pray tell does the .net datetime class  have to do with FLEE?


On Friday, October 8, 2010 11:35:06 AM UTC-4, hemanth mpk wrote:

Ivan Peev

unread,
Dec 29, 2014, 9:50:29 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
Bill,

FLEE is a Fast Lightweight Expression Evaluator and it is based on .NET . It has a lot to do with .NET and the available classes.

William Ross

unread,
Dec 29, 2014, 10:40:43 PM12/29/14
to coz...@googlegroups.com, heman...@gmail.com
Trying to use your product is a bit of a quest. One must be very determined. One must relentlessly pursue clear answers. I'm sure you don't understand why you are not more successful despite your obvious intelligence.

tel...@gmail.com

unread,
Dec 29, 2015, 12:00:36 PM12/29/15
to COZYROC
I am trying to use the FTPS connection to get the list of Remote Files. I need this list so that I can compare which files i have already processed. My SSIS package will run once every day and look for new files by comparing to a local DB table. 

How do I accomplish this? Please provide detailed examples as I have not been successful so far in getting this to work. 

I used the SFTP task, did the FTPS connection, set the Action= Get remote files list, and then put a Foreach Loop. But at the ForEach loop container, I am unable to iterate/parse the results that come back from the SFTP task. I am hoping that this result contains a list of FIleNames, but that doesn't seem to be the case.

Ivan Peev

unread,
Dec 29, 2015, 12:05:50 PM12/29/15
to COZYROC
Hi,

The result returned by the SFTP Task is array object which contains IFileInfo objects. We have posted multiple code examples on the documentation page here.
Reply all
Reply to author
Forward
0 new messages