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

Author Message
supermankelly
[View user's profile]

Joined: 2017-03-13
Posts: 2
Location: Essex
Hi,

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.

Code:
 
         
If session.FileExists(toFile) Then                                                                       
    session.RemoveFiles(toFile)
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???

Code:
    Public Function Main() As Integer

        Try
            ' Setup session options
            Dim sessionOptions As New SessionOptions
            With sessionOptions
                .Protocol = Protocol.Sftp
                .HostName = "xx-xxxx.xxx-xxx.xxxx"
                .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
                session.Open(sessionOptions)

                ' 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
                transferResult.Check()

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

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

    End Function



Cheers
Andrew
supermankelly
[View user's profile]

Joined: 2017-03-13
Posts: 2
Location: Essex
Looks like this isn't isolated issue (https://winscp.net/forum/viewtopic.php?t=15326) 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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26138
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License