How to Open a Stored Session

Advertisement

lee_qiao_2000@yahoo.com
Joined:
Posts:
2
Location:
NY

How to Open a Stored Session

Hi!

I know we can open a session using SessionOptions class. How can we open a session with stored session? Sometimes we have to use proxy, which can be specified in the GUI and stored, and this can't be added in SessionOptions.

Thanks in advance.

L

Reply with quote

Advertisement

Vara04
Joined:
Posts:
5
Location:
France

Re: How to Open a Stored Session

lee_qiao_2000@yahoo.com wrote:

martin wrote:

It is not supported.
You can configure any session settings, including proxy, using SessionOptions.AddRawSettings though:
https://winscp.net/eng/docs/library_sessionoptions_addrawsettings

That's good. Thank you!

I try this and it seems to work
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "TestFTPLocal",
};

using (Session session = new Session())
{
   session.DefaultConfiguration = false;
   session.IniFilePath =@"D:\yourdir\winscp.ini";
   // Connect
   session.Open(sessionOptions);
   ...
}    

And in "D:\yourdir\winscp.ini", I set my conf
[Sessions\TestFTPLocal]
HostName=myserver
PortNumber=21
UserName=myuser
FSProtocol=5
Password=[encryptPwd]    

I copy this from winscp.ini of winscp GUI

I hope it helps you

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,271
Location:
Prague, Czechia

Re: How to Open a Stored Session

Yes this works. I suggest you use my suggested approach anyway.
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum