Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Element session@0 already read to the end Source

Set Session.SessionLogPath and Session.DebugLogPath and post both logs (using the latest version of WinSCP).
shailu0287

This is the code for creating session.

private SessionOptions GetSessionOptions(string password)
{
  // Setup session options
  var sessionOptions = new SessionOptions
  {
    Protocol = (this._ftpType == FtpType.ActiveFTP || this._ftpType == FtpType.PassiveFTP)
      ? Protocol.Ftp
      : Protocol.Sftp,
    HostName = this._host,
    UserName = this._userName,
    Password = password,
    PortNumber = this._port,
    FtpMode = this._ftpType == FtpType.ActiveFTP ? FtpMode.Active : FtpMode.Passive,
    SshHostKeyPolicy = this._ftpType == FtpType.SFTP ? SshHostKeyPolicy.AcceptNew : SshHostKeyPolicy.Check
  };
 
  if (sessionOptions.Protocol == Protocol.Sftp && !string.IsNullOrEmpty(this._privateKeyFile))
  {
    sessionOptions.SshPrivateKeyPath = this._privateKeyFile;
  }
 
  return sessionOptions;
}
shailu0287

Element session@0 already read to the end Source

I am trying to upload files using the WinSCP C# library on FTP. I am getting the following error randomly:
Element session@0 already read to the end Source

Sometimes my code works fine sometimes I do get this error. Currently, I am using the 5.19.6 version the of WinSCP library.

Any help on this would be appreciated.

Thanks in advance.