Post a reply

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)


Topic review


Re: session.FileExists hangs when no file but returns 'true' when when there is as expected.

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.

Looks like this isn't isolated issue ( with FileExists hanging when returning an error condition. This works on another of our SFTP servers. So I will post up the differences of the two shortly once our admin sends me a summary.

session.FileExists hangs when no file but returns 'true' when when there is as expected.


I'm using VB .net within Visual Studio but the FileExists hangs and does nothing when no file exist on remote SFTP server. ie it doesn't receive a 'false'. PutFiles and GetFiles seem fine.


If session.FileExists(toFile) Then                                                                       
End If

Also MoveFiles also hangs if the file moved to exists. Is there a overwrite for this? Or at least return an error code so it can be handled.

And RemoveFiles hangs if no file exists to remove.

Just used this sites exact sample as provided and this hanged when the GET file didn't exist???

    Public Function Main() As Integer

            ' Setup session options
            Dim sessionOptions As New SessionOptions
            With sessionOptions
                .Protocol = Protocol.Sftp
                .HostName = ""
                .UserName = "xxxxxx"
                .PortNumber = "8822"
                .SshHostKeyFingerprint = "ecdsa-sha2-nistp521 x xx:ex:xx:fe:xx:bc:ex:cx:xx:xx:xx:xx:cx:xc:xb:xx"
                .SshPrivateKeyPath = "C:\xxxx\xxxxx\Documents\private_key.ppk"
            End With

            Using session As New Session
                ' Connect

                ' Download files
                Dim transferOptions As New TransferOptions
                transferOptions.TransferMode = TransferMode.Binary

                Dim transferResult As TransferOperationResult
                transferResult = session.GetFiles("\Test\Outbox\Pricelists\xxxx-pricebooks-global.xml", "C:\Users\Documents\xxxx-pricebooks-global.xml", False, transferOptions)

                ' Throw on any error

                ' Print results
                For Each transfer In transferResult.Transfers
                    Console.WriteLine("Download of {0} succeeded", transfer.FileName)
            End Using

            Return 0
        Catch e As Exception
            Console.WriteLine("Error: {0}", e)
            Return 1
        End Try

    End Function