GetFiles with File Mask - WeOnlyDo Discussion board

GetFiles with File Mask (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Limey, Monday, September 08, 2014, 23:23 (3727 days ago)

Is it possible to get files using a mask? As an example, "F*.FOO*.zip"

I do have the eventLoop example working, but as you can see from my mask example, I have many wild cards I would need to program (some have as many as four)

Is it possible to use wildcards in the eventLoop? I guess that could make things simpler to search for.


Thanks

GetFiles with File Mask

by wodSupport, Tuesday, September 09, 2014, 08:36 (3727 days ago) @ Limey

Limey,

hi. Can you be more specific about what is eventLoop? Which sample are you referring to exactly?

Kreso

GetFiles with File Mask

by Limey, Tuesday, September 09, 2014, 16:09 (3726 days ago) @ wodSupport

I'm adding the following event handler that is called executed before each file is downloaded via GetFiles()

WeOnlyDo.Client.SFTP wodSFTP = new WeOnlyDo.Client.SFTP();
wodSFTP.LoopItemEvent += new WeOnlyDo.Client.SFTP.LoopDelegate(wodSFTP_LoopItemEvent);

which then checks each file to see if it should be downloaded.


void wodSFTP_LoopItemEvent(object Sender, WeOnlyDo.Client.SFTP.LoopArgs Args)
{
if (Args.ItemType == WeOnlyDo.Client.SFTP.DirItemTypes.Directory)
{
Args.Skip = false;
}
else
{
//Check remote files for desire extension.
if (Args.RemoteFile.EndsWith(".txt"))
{
Args.Skip = false;
}
else
{
Args.Skip = true;
}

}

}

instead of checking each part of the file separately, I would like to use a mask. Does is support masks? Regular expressions could also do the trick.

GetFiles with File Mask

by wodSupport, Tuesday, September 09, 2014, 18:41 (3726 days ago) @ Limey

Hi.

Oh, in LoopItem you could, for example, use Regular expressions to make a choice if file should be processed or not.

You could use regular expression against Args.RemoteFile with some rule of your own. I'm not regex expert so I can't give exact guidance, I can only offer this idea. You could check out some regex samples here:

http://msdn.microsoft.com/en-us/library/ms228595.aspx
and for example here
http://www.dotnetperls.com/regex-match

Hope this helps!

Kreso