SFTPClient 无限连接

问题描述 投票:0回答:0

我有这段使用 Renci.SshNet 包的代码

            var config = new
            {
                Host = "X",
                Port = X,
                UserName = "X",
                Output = "/OUT",
                KeyFile = new PrivateKeyFile("X")
            };
            string output = "./test56.txt";
            string filePath = "X\\test56.txt";
            using (FileStream inputStream = File.OpenRead(filePath))
            {
                using (SftpClient client = new SftpClient(config.Host, config.Port, config.UserName, config.KeyFile))
                {
                    client.Connect();
                    client.ChangeDirectory(config.Output);
                    client.UploadFile(inputStream, output, true);
                }
            }

应该连接到远程 sftp 主机并上传文件 在我的解决方案中,出于某种原因,它运行了 connect() 函数并且永远不会完成。

但在我编写的示例代码中它有效。 示例项目和解决方案均使用 .net framework 4.7.2

你知道为什么它会 connect() 没有完成吗?

c# sftp .net-framework-version .net-4.7.2
© www.soinside.com 2019 - 2024. All rights reserved.