Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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: Getting error on transferResult.Check();

It's probably a firewall issue.
See https://winscp.net/eng/docs/ftp_modes

Can you download a file from that FTP server anyhow on the "server", where you run your C# program? Using WinSCP GUI? Or using any other FTP client?
mennettip

Getting error on transferResult.Check();

Hello. I have several C# programs using the WinSCP DLL. Each of the C# programs is compiled as a console app and run as a simple .exe file, which is later kicked off by an SQL Server job.

I recently coded a new program that uses ftp. All the others use SFTP. See below C# code.

I added some debug code to the c# program and it looks like it opens the session fine, but when it hits transferResult.Check(), I get this error:
Error listing directory '/Export_UAT'.
Transfer channel can't be opened. Reason: No connection could be made because the target machine actively refused it.
Could not retrieve directory listing


I've also contacted the people I'm trying to connect to and they tell me they don't manage IP addresses on their end.

Also when I run this on my own PC as an exe, it works fine. When it's run on the server it gives the error listed above. All the other WinSCP programs work fine. The only difference being this is a different vendor, and it's FTP, not SFTP. Any help would be great. Thanks

SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    HostName = "HostName.com",
    UserName = "MyUserName",
    Password = "password123",
    FtpSecure = FtpSecure.Implicit,
    TlsHostCertificateFingerprint = "blah.....",
};
 
session.Open(sessionOptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
 
TransferOperationResult transferResult;
transferResult = session.GetFiles(SFTPFolder, MyDownLoadFolder, false, transferOptions);
transferResult.Check();
foreach (TransferEventArgs transfer in transferResult.Transfers)
{