WinSCP.NET Node: where to define the proxy?

I can define a proxy server using the WinSCP GUI. If I do this, I can connect to the remote host. But in the code, I did not find a way to declare a proxy server for WinSCP.

In this case, I get

The remote server returned an error (407) Proxy authentication required.

My code is:

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(); } 
+7
source share
1 answer

Use SessionOptions.AddRawSettings to configure raw session settings appropriate for your proxy server.

For example:

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

See the complete list for setting up raw sessions .


Although it’s easier to configure a proxy server in the WinSCP GUI and create a code template for you .

+10
source

All Articles