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: Possible bug in Session.PutFile

What version of WinSCP are you using? Do you have the latest one? Please set Session.DebugLogPath and attach a complete debug log showing the problem. Also a complete exception callstack.
wild-cursor

Possible bug in Session.PutFile

I have been using this client for some time. It's an awesome library.
I am doing a simple upload via streaming.
Usually, when I am uploading I use the physical path method as I have the file physically.
Currently, I am downloading the file from one location and uploading it to another location.
Using this method avoids creating unnecessary files locally.

I am getting an error on this line.
https://github.com/winscp/winscp/blob/5.18.2-beta/dotnet/Session.cs#L823

I am not familiar with the internals but I looking at code.
I think this check is incorrect.
this._process.StdIn is going to be null in the beginning.

Below is my code for calling this method.
https://winscp.net/eng/docs/library_session_putfile

public void UploadFile(Stream stream, string remotePath)
{
    // Setup session options
    var sessionOptions = new SessionOptions
    {
        Protocol = Protocol.Ftp,
        HostName = FtpHostName,
        UserName = FtpUser,
        Password = FtpPassword
    };
 
    using Session session = new Session();
    // Connect
    session.Open(sessionOptions);
 
    if (session.Opened)
    {
        session.PutFile(stream, remotePath);
    }
}