我可以使用WinSCP GUI定义代理服务器.如果我这样做,我就能连接到远程主机.但在代码中我找不到为WinSCP声明代理服务器的方法.
在这种情况下,我收到了
远程服务器返回错误(407)需要代理身份验证.
我的代码:
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();
}
Run Code Online (Sandbox Code Playgroud)