connecting to FTP server - The remote server returned an error: (550)

我们两清 提交于 2019-12-29 08:48:12

问题


I'm getting the error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)." when I call my function sendFile2FTP

    Function sendFile2FTP(fileNameLocal As String, fileNameServer As String, user As String, password As String) As String


        Dim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create(fileNameServer)
        ftpRequest.Credentials = New Net.NetworkCredential(user, password)
        ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
        Try
            Dim ficheiro() As Byte = System.IO.File.ReadAllBytes(fileNameLocal)
            Dim ftpStream As System.IO.Stream = ftpRequest.GetRequestStream()
            ftpStream.Write(ficheiro, 0, ficheiro.Length)
            ftpStream.Close()
            ftpStream.Dispose()

            Return "True"
        Catch ex As Exception
            Return ex.Message

        End Try

  End Function

And this are the parameters that i'm sending to the function (which are all valid)

fileNameLocal -> C:\Users\user\Documents\Visual Studio 2013\Projects\AgenteExportDebitosCC\AgenteExportDebitosCC\bin\Debug\file02-05-2014.xml

fileNameServer -> ftp://ftp.server.com/intranet/file02-05-2014.xml
user -> user

password ->password

What am I doing wrong?

Edit:

I'm not sure if this is a permission issue, but I am able to create files with filezilla using the same credentials...


回答1:


The issue was regarding the ftp address. Instead of

ftp://ftp.server.com/intranet/file02-05-2014.xml

I had to use the username in the address

ftp://username@ftp.server.com/server.com/intranet/file02-05-2014.xml



来源:https://stackoverflow.com/questions/23431776/connecting-to-ftp-server-the-remote-server-returned-an-error-550

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!