Post a reply

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: GetFiles() transfers empty File

Chaos wrote:

found it, its evil!
Session.FileExists will return true for a relative path
Session.GetFiles will just create an empty file
[/b]

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Chaos

GetFiles() transfers empty File

Hi Guys,
I'm starting with the WINSCP Lib and it looks quite good.
Now I'm using the WinSCP Client to compare what I am doing.
I have a simple text file on an sftp with a few lines of content; when I transfer it, it arrives beeing an empty file.
Here is the code I use:

 using (var session = Connect())

            {
                if(!session.FileExists(fileName))
                {
                    throw new FileNotFoundException(fileName);
                }
                var tmp = Path.GetTempFileName();
                var result = session.GetFiles(fileName, tmp);
                if(!result.IsSuccess)
                {
                    throw new AggregateException(result.Failures);
                }
                return tmp;
            }


found it, its evil!
Session.FileExists will return true for a relative path
Session.GetFiles will just create an empty file
[/b]