Connect to an FTP server. The remote server responded with an error: (550)

I get the error message "The remote server responded with an error: (550) File is not available (for example, the file was not found, there is no access)." when i call my sendFile2FTP function

    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 these are the parameters that I send to the function (they 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 can create files with file files using the same credentials ...

+4

Source: https://habr.com/ru/post/1539022/


All Articles