Topic "Files uploaded to FTP server dont appear on the server"

Author Message
dwinn86
[View user's profile]

Joined: 2012-08-08
Posts: 42
Location: London
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:

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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Please set Session.SessionLogPath and attach a log file here.
_________________
Martin Prikryl
dwinn86
[View user's profile]

Joined: 2012-08-08
Posts: 42
Location: London
Hi,

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

Here is my code:

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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
You need to set that before calling Session.Open.
Otherwise, you should get an exception. Unless you are using an old version of WinSCP.
_________________
Martin Prikryl
dwinn86
[View user's profile]

Joined: 2012-08-08
Posts: 42
Location: London
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)
dwinn86
[View user's profile]

Joined: 2012-08-08
Posts: 42
Location: London
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
[View user's profile]

Joined: 2012-08-08
Posts: 42
Location: London
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.
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