try
{
using (var client = new SftpClient(host, port, username, password))
{
client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(sftpalivetimeinseconds);
client.Connect();
if (client.IsConnected)
{
Debug.WriteLine(“I’m connected to the client”);
using (var fileStream = new FileStream(newSubFolderPath, FileMode.Open))
{
client.BufferSize = 4 * 1024; // bypass Payload error large files
var remoteFileName = Path.GetFileNameWithoutExtension(newSubFolderPath);
client.UploadFile(fileStream, remoteFileName);
}
}
else
{
Debug.WriteLine("I couldn't connect");
}
}
}
catch (Renci.SshNet.Common.SshConnectionException ex)
{
Debug.WriteLine($"An error occurred: {ex.Message}");
Debug.WriteLine($"SSH connection error: {ex.InnerException?.Message}");
}
catch (Exception ex)
{
Debug.WriteLine($"An error occurred: {ex.Message}");
}
}
이런 식으로 sftp 로 업로드를 하려고 합니다.(2023 03 21 예제 코드 다시 올림)
그런데 업로드 하려고 하면 “channel was closed” 라는 에러 메시지가 뜨는데요…
어떤 부분을 확인해서 수정하면 되는지 알려주시면 감사하겠습니다