当我使用SftpClient.UploadFile()(在SSH.NET库上)时,如何获得响应状态和描述?

时间:2015-12-09 04:22:20

标签: c# ssh.net

using (SftpClient client = new SftpClient(ftpUrl, port, username, password))
{
    KeyValuePair<string, CipherInfo> temp = client.ConnectionInfo.Encryptions.FirstOrDefault(e => e.Key == sftpEncryption);
    if (temp.Key == sftpEncryption)
    {
        client.ConnectionInfo.Encryptions.Clear();
        client.ConnectionInfo.Encryptions.Add(temp);
    }

    client.Connect();
    Stream stream = null; // some data to upload

    // The upload works fine but how can I see the response code (numeric code) and the response message from the server.
    client.UploadFile(stream, "my_data.bin"); 
} 

UploadFile方法完美无缺。但是我希望在上传完成后从FTP服务器获取状态代码(数字代码)和响应消息。 UploadFile方法返回void,回调给我一个ulong,我认为是上传文件的大小。我有没有机会从这个库中获取服务器的响应信息?

0 个答案:

没有答案