Download Files based on extension

Advertisement

PPATEL
Joined:
Posts:
6

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);

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

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

Reply with quote

Advertisement

You can post new topics in this forum