gpt4 book ai didi

c# - WinSCP .NET 程序集 : Where to define proxy?

转载 作者:太空狗 更新时间:2023-10-29 18:22:42 30 4
gpt4 key购买 nike

我可以使用 WinSCP GUI 来定义代理服务器。如果我这样做,我就可以连接到远程主机。但是在代码中我找不到为 WinSCP 声明代理服务器的方法。

在这种情况下我收到

Remote server returned an error (407) Proxy authentication required.

我的代码:

SessionOptions sessionOptions = new SessionOptions
{
Protocol = protocol,
HostName = hostname,
UserName = user,
Password = pass,
PortNumber = portnumber
};

using (Session session = new Session())
{
session.ExecutablePath = @"C:\Program Files (x86)\WinSCP\WinSCP.exe";
session.Open(sessionOptions);

TransferOptions options = new TransferOptions();
options.FileMask = mask;


SynchronizationResult synchronizationResult;
synchronizationResult =
session.SynchronizeDirectories(mode, local, path, deletefiles, options: options);

synchronizationResult.Check();
}

最佳答案

使用 SessionOptions.AddRawSettings配置适合您的代理类型的原始 session 设置。

例如:

sessionOptions.AddRawSettings("ProxyMethod", "3");
sessionOptions.AddRawSettings("ProxyHost", "proxy");

查看 raw sessions settings 的完整列表.


虽然更简单的方法是 configure the proxy在 WinSCP GUI 中并拥有它 generate a code template给你。

关于c# - WinSCP .NET 程序集 : Where to define proxy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13375300/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com