3

我正在使用 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”的属性。

4

0 回答 0