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: Needing help scripting an auto download from a SFTP in C#

deadpanpython wrote:

It has it uploading files while I'm needing the opposite. Would I need to change "transferResult = session.PutFiles" to "transferResult = session.GetFiles" ?

Correct, use Session.GetFiles:
https://winscp.net/eng/docs/library_session_getfiles

Also with the SshHostKeyFingerprint since I do not have the fingerprint is there a way I just bypass that? I saw in another forum post how you were able to bypass it using powershell.

You need to have the fingerprint.
See https://winscp.net/eng/docs/faq_hostkey

And also how do I add a specialized port number to be able to connect to the SFTP?

Use SessionOptions.PortNumber:
https://winscp.net/eng/docs/library_sessionoptions

Also how would I go about scheduling a time to run say a nightly download? Is that a Windows Scheduler thing that I would have to set up in windows?

Yes. For scheduling see:
https://winscp.net/eng/docs/guide_schedule
Note that it deals with scheduling WinSCP script, not a C# application. So just replace WinSCP.exe executable with your application.
deadpanpython

Needing help scripting an auto download from a SFTP in C#

Hey everyone! I am needing some help to make a C# script to run an auto download from our SFTP. I did find this link https://winscp.net/eng/docs/library and the C# example is my template that I'm using. I do have a few questions on the code though. It has it uploading files while I'm needing the opposite. Would I need to change "transferResult = session.PutFiles" to "transferResult = session.GetFiles" ?

Also with the SshHostKeyFingerprint since I do not have the fingerprint is there a way I just bypass that? I saw in another forum post how you were able to bypass it using powershell.

And also how do I add a specialized port number to be able to connect to the SFTP?

Also how would I go about scheduling a time to run say a nightly download? Is that a Windows Scheduler thing that I would have to set up in windows?

I do appreciate it guys! I am new to coding and just trying to get my orientation with all of this. Any help you can give I would greatly appreciate it!