我可以使用 WinSCP GUI 定义代理服务器.如果我这样做,我可以连接到远程主机.但是在代码中我找不到为 WinSCP 声明代理服务器的方法.
I am able to define the proxy server by using the WinSCP GUI. If I do this I am able to connect to a remote host. But in code I don't find a way to declare the proxy server for WinSCP.
在这种情况下我收到
远程服务器返回错误 (407) 需要代理身份验证.
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)WinSCPWinSCP.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 配置适合您的代理类型的原始会话设置.
Use the SessionOptions.AddRawSettings to configure raw session settings appropriate for your kind of proxy.
例如:
sessionOptions.AddRawSettings("ProxyMethod", "3");
sessionOptions.AddRawSettings("ProxyHost", "proxy");
查看原始会话设置的完整列表.
虽然更简单的方法是在 WinSCP GUI 中配置代理 并拥有它为您生成代码模板.
Though a way easier is to configure the proxy in WinSCP GUI and have it generate a code template for you.
这篇关于WinSCP .NET 程序集:在哪里定义代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ASP.NET Core 使用 Azure Active Directory 进行身份验证并ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 进行身
ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用)
如何获取守护进程或服务器到 C# ASP.NET Web API 的How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何获取守护进程或服务器到 C# ASP.N
异步调用时 Azure KeyVault Active Directory AcquireTokenAAzure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(异步调用时 Azure KeyVault Active Directory AcquireTokenAsync 超
使用电子邮件地址和应用程序密码从 oauth2/tokenGetting access token using email address and app password from oauth2/token(使用电子邮件地址和应用程序密码从 oauth2/token 获取访问令
新的 Azure AD 应用程序在通过管理门户更新之前无New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 应用程序在通过管理门户更新之前无法运行