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

dwinn86

Hi,

I managed to sort this out.

I was connecting successfully via SFTP, but the way my PutFiles() method was implemented was wrong.

Thank you for all your help.
dwinn86

Ok, I have managed to get a log file to be produced.

Can somebody please tell me what I should be looking for within this file?

Many thanks
dwinn86

I put it to just before I open the session, and still not getting anything.

All I get is a page in IE after I try to upload the file, saying Internet explorer Cannot display the webpage.

I am using WinSCP 5.0.8 (Build 2438)
martin

You need to set that before calling Session.Open.
Otherwise, you should get an exception. Unless you are using an old version of WinSCP.
dwinn86

Hi,

I do not appear to be getting a log file come out at all.

Here is my code:

Protected Function ProcessFiles() As String


        Dim Path As String
        Dim LocalPath As String
        Dim RemotePath As String
        Path = "C:\WinSCP\WinSCP.exe"
        LocalPath = "C:\" + FileUpload1.FileName
        'RemotePath = "ftp://user:password@xx.x.xx.xx/In/"

        Try
            ' Setup session options
            Dim sessionOptions As New SessionOptions
            MsgBox("Processing")
            With sessionOptions
                .Protocol = Protocol.Sftp
                .HostName = "xx.xx.xx.xx"
                .PortNumber = 22
                .UserName = "user"
                .Password = "password"
                .SshHostKey = "ssh-rsa xxxx xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

            End With

            'Set up the session
            'Using session As Session = New Session
            Dim mySession As New Session
                ' Connect

            mySession.ExecutablePath = Path

            mySession.Open(sessionOptions)
            Dim transferResult As TransferOperationResult

                ' Upload files
            Dim transferOptions As New TransferOptions
                ' Print results
            'Dim transfer As TransferEventArgs
            'For Each transfer In transferResult.Transfers
            'Console.WriteLine("Upload of {0} succeeded", transfer.FileName)
            'Console.Read()
            'Next

            If (mySession.Opened) Then

                transferOptions.TransferMode = TransferMode.Binary

                'transferResult = session.PutFiles(FileUpload1.ToString, "/", True, transferOptions)
                transferResult = mySession.PutFiles(LocalPath, RemotePath, False, transferOptions)

                ' Throw on any error
                transferResult.Check()
                mySession.SessionLogPath = "c:\WinSCP\log.log"
            End If

            'End Using

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

            Return 1
        End Try

    End Function


Any advice will be greatly apreciated.

Thanks
martin

Re: Files uploaded to FTP server dont appear on the server

Please set Session.SessionLogPath and attach a log file here.
dwinn86

Files uploaded to FTP server dont appear on the server

Hello,

I have created a site in Visual Studio using VB.Net and ASP.Net that allows the upload and download of files to and from an FTP server via SFTP

I have produced the code, and my site allows a file to be uploaded via SFTP (WinSCP) but when I go on to the server, the files that I have uploaded do not appear to be there.

Here is my code:

If (mySession.Opened) Then


                transferOptions.TransferMode = TransferMode.Binary

                'transferResult = session.PutFiles(FileUpload1.ToString, "/", True, transferOptions)
                transferResult = mySession.PutFiles(LocalPath, RemotePath, False, transferOptions)

                ' Throw on any error
                transferResult.Check()

            End If


Can anybody please advise on whyt his is happening?

Many thanks