I need the expert help. I have written the C# console base application. In which I have to upload the zip file to FTPS server. Every time I am getting the connection refuse error. But when I connect by the FileZilla its connected and working fine.
I am using FTP Protocol and Encryption type is "Required Explicit FTP over TLS" logon type normal (see the below screen shots).
The exception message as below : "Connection failed.\r\nTLS connect: error in error\r\nCan't establish TLS connection\r\nDisconnected from server\r\nConnection failed"
Please provide any sample code or help me to correct this code.
My sample C# sample code as below :
using System;
using System.Collections.Generic;
using System.IO;
using WinSCP;
namespace FTPS
{
class Program
{
static void Main(string[] args)
{
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "CIR-SVN34",
UserName = "buildmachine",
Password = "Password",
FtpSecure = FtpSecure.Implicit,
PortNumber = 990
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult =
session.PutFiles(@"C:\BuildProcess\Testing.zip", @"/Apps-Panel Dev Daily Build/", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Working only with FileZilla client