I am uploading 4000 zip files of size 85 KB of each using over Linux Server using SFTP in C# WPF application. This whole process takes 30 minutes.
Is there any way to speed up the uploading using SFTP?
I'm using WinSCP .NET assembly:
https://winscp.net/eng/docs/library
I had also used Chilkat previously.
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WinSCP;
namespace SFTP_Demo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
string line;
SessionOptions sessionoptions = new SessionOptions()
{
Protocol = WinSCP.Protocol.Sftp,
HostName = "172.168.1.7",
PortNumber = 22,
UserName = "lduser",
Password = "lduser",
GiveUpSecurityAndAcceptAnySshHostKey = true
};
using (Session session = new Session())
{
session.Open(sessionoptions);
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
System.IO.StreamReader file = new System.IO.StreamReader(txtFile.Text);
while ((line = file.ReadLine()) != null)
{
transferResult = session.PutFiles(@"D:\Test\signature\ldoutput\"+line, "/SFTP/", false, transferOptions);
transferResult.Check();
counter++;
strbldr = strbldr.AppendLine(string.Format("{0} Upload of {1} succeeded", counter + 1.ToString(), line));
}
}
}
}
}