Uploading a TXT File to FTP with Visual Studio Script Task
Hi,
Uploading some txt files from a local folder to a specific FTP address (I'm using this,
I've installed WinSCP 5.19 & .NET assembly and followed the instructions from this link:
https://winscp.net/eng/docs/library_ssis
But I think WinSCP can't recognize my FTP link. Here's my C# code, any suggestions? Thank you.
Uploading some txt files from a local folder to a specific FTP address (I'm using this,
ftp://ftpint/sales/to_system/
) is one of my daily routines. I'm using ZappySys for automate this routine, but my company doesn't want to use it anymore, so i think WinSCP could be a good option.
I've installed WinSCP 5.19 & .NET assembly and followed the instructions from this link:
https://winscp.net/eng/docs/library_ssis
But I think WinSCP can't recognize my FTP link. Here's my C# code, any suggestions? Thank you.
using System; using WinSCP; class Example { public static int Main() { try { // Setup session options SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "xxx", UserName = "xxx", Password = "xxx", SshHostKeyFingerprint = "SHA-256 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" }; 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:\Users\Diomedas\test\*", "ftp://ftpint/sales/to_system/", false, transferOptions); // Throw on any error transferResult.Check(); // Print results foreach (TransferEventArgs transfer in transferResult.Transfers) { Console.WriteLine("Upload of {0} succeeded", transfer.FileName); } } return 0; } catch (Exception e) { Console.WriteLine("Error: {0}", e); return 1; } } }