Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Download Files based on extension

Make sure that the remoteLocation ends with a slash.
Basically, you need:
session.GetFiles("/remote/location/*.txt", ...);


Easier might be to use Session.GetFilesToDirectory. With it, you do not have to deal with the slashes:
session.GetFilesToDirectory(remoteLocation, localDestination, "*.txt", delRemoteFile, transferOptions);

https://winscp.net/eng/docs/library_session_getfilestodirectory

See also https://winscp.net/eng/docs/faq_script_vs_gui#inputs
PPATEL

Download Files based on extension

Hello,

I want to download a file using C# WINSCP based on file extension. Here is my code to do that, but it doesn't work.
session.GetFiles(remoteLocation + "*txt", localDestination, delRemoteFile, transferOptions);

AM I missing anything?

This code below:
Downloads all the files.
session.GetFiles(remoteLocation + "*", localDestination, delRemoteFile, transferOptions);