Getting error on transferResult.Check();

Advertisement

mennettip
Joined:
Posts:
2
Location:
United States

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

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
32,896
Location:
Prague, Czechia

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?

Reply with quote

Advertisement

You can post new topics in this forum