使用WinSCP .NET程序集下载文件时“无法获取文件属性”错误

时间:2013-08-12 12:18:21

标签: c# winscp winscp-net

我正在使用WinSCP .NET库将文件从Linux传输到Windows。 我有一个代码,但文件没有下载。

有人可以查看这段代码,看看我做错了什么。

在我看来,在以transferResult开头的代码行中出现了一些问题。

我的代码:

SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = "sj1slm612",
    UserName = "username",
    Password = "password",
    SshHostKeyFingerprint = "ssh-rsa 2048 fa:e9:58:24:1b:41:a3:15:63:0d:c0:72:41:5d:51:7a"
};

using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);

    // Download Files

    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;

    TransferOperationResult transferResult;
    transferResult = session.GetFiles("/apps/instances/sj1slm612/express_13000/configuration/standalone-full.xml", "C:\\Users\\karansha\\Desktop\\sj1slm612\\express_13000", false, transferOptions);
    transferResult = session.GetFiles("/apps/instances/sj1slm612/query_13100/configuration/standalone-full.xml", "C:\\Users\\karansha\\Desktop\\sj1slm612\\query_13100", false, transferOptions);
    transferResult = session.GetFiles("/apps/instances/sj1slm612/wppapi_13200/configuration/standalone-full.xml", "C:\\Users\\karansha\\Desktop\\sj1slm612\\wppapi_13200", false, transferOptions);
    transferResult = session.GetFiles("/apps/instances/sj1slm612/wppgui_13300/configuration/standalone-full.xml", "C:\\Users\\karansha\\Desktop\\sj1slm612\\wppgui_13300", false, transferOptions);

    // Throw Error
    transferResult.Check();

    Console.WriteLine("All Files Downloaded");
    Console.ReadLine();
}

错误信息是:

  

无法获取文件'/apps/instances/sj1slm612/wppgui_13300/configuration/standalone-full.xml'的属性。

0 个答案:

没有答案