現在、WinSCPを使用して1kbファイルをサーバーに転送するために、C#でクライアントコードを書き込もうとしています。次のコードは動作しますが、完全な手順には約11秒かかります。コードは、接続のネゴシエーションとユーザーの認証に10秒かかります。実際のファイル転送は非常に高速です。WinSCP SCP接続時間の改善
Process winscp = new Process();
winscp.StartInfo.FileName = "winscp.com";
winscp.StartInfo.Arguments = "/xmllog=\"" + "sftp.txt" + "\"";
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();
// Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch abort");
winscp.StandardInput.WriteLine("option confirm off");
List<string> FtpCommands = new List<string>
{
string.Format("open scp://{0}:{1}@{2}:22",CONNECTION_SFTP_USER,CONNECTION_SFTP_PASSWORD, CONNECTION_SFTP_IP),
string.Format("put \"{0}\" /home/pi/progs/programs/{1}", file, program),
"exit"
};
LogMessage("Sending ftp commands");
foreach (var ftpCommand in FtpCommands)
{
LogMessage(ftpCommand);
winscp.StandardInput.WriteLine(ftpCommand);
}
winscp.StandardInput.Close();
// Collect all output (not used in this example)
string output = winscp.StandardOutput.ReadToEnd();
// Wait until WinSCP finishes
winscp.WaitForExit();
私のコードは、サーバーを編集せずWinSCPのウェブサイト
https://winscp.net/eng/docs/guide_dotnet#csharp_example
から「フルC#の例」の編集したバージョンであり、私は転送時間を短縮するために作ることができるすべての変更はありますか?