uploading file to FTP fails

I am trying to upload a file to an ftp using vb.net but it fails with this message yet i can access and create/copy file to that ftp using windows explorer. Massage given is "The remote server returned an error: (553) File name not allowed".

Code i have is

  Public ftp As New FTPUtils("ftpuser", "*****")

    Public Class FTPUtils
        Private _netcredentials As System.Net.NetworkCredential
        Private _logger As New Logging.AspLog
        Sub New(ByVal username As String, ByVal password As String)
            setNetworkCredentials(username, password)
        End Sub
        Public Sub UploadFile(ByVal _FileName As String, ByVal _UploadPath As String)
            Dim _FileInfo As New System.IO.FileInfo(_FileName)
            Dim _FtpWebRequest As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(New Uri(_UploadPath)), System.Net.FtpWebRequest)
            _FtpWebRequest.Credentials = _netcredentials
            _FtpWebRequest.Proxy = Nothing
            _FtpWebRequest.KeepAlive = False
            _FtpWebRequest.Timeout = 20000
            _FtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
            _FtpWebRequest.UseBinary = True
            _FtpWebRequest.ContentLength = _FileInfo.Length
            Dim buffLength As Integer = 2048
            Dim buff(buffLength - 1) As Byte
            Dim _FileStream As System.IO.FileStream = _FileInfo.OpenRead()
            Try
                Dim _Stream As System.IO.Stream = _FtpWebRequest.GetRequestStream()
                Dim contentLen As Integer = _FileStream.Read(buff, 0, buffLength)
                Do While contentLen <> 0
                    _Stream.Write(buff, 0, contentLen)
                    contentLen = _FileStream.Read(buff, 0, buffLength)
                Loop
                _Stream.Close()
                _Stream.Dispose()
                _FileStream.Close()
                _FileStream.Dispose()
            Catch ex As Exception
                _logger.WriteEntry("Upload Error: " & ex.Message)
            End Try
        End Sub
        Private Sub setNetworkCredentials(ByVal username As String, ByVal password As String)
            _netcredentials = New System.Net.NetworkCredential(username, password)
        End Sub
    End Class


         ftp.UploadFile(csvFile, "ftp://ftpuser@10.156.146.16//PAKAPAKA/" & Trim(Mid(csvFile, csvFile.ToString.LastIndexOf("\") + 2, 200)))

it fails at line   Dim _Stream As System.IO.Stream = _FtpWebRequest.GetRequestStream()
LVL 1
Anthony MatovuBusiness Analyst, MTN UgandaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
well the message is pretty clear. The filename is not valid.

Have you tried something as simple as:
ftp.UploadFile(csvFile, "ftp://ftpuser@10.156.146.16//PAKAPAKA/test.txt")

Open in new window

1
Anthony MatovuBusiness Analyst, MTN UgandaAuthor Commented:
Thank you members, i had an issue in my address, i removed the "//" , instead of "ftp://ftpuser@10.156.146.16//PAKAPAKA/" i did "ftp://ftpuser@10.156.146.16/PAKAPAKA/"

and it worked
Anthony
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony MatovuBusiness Analyst, MTN UgandaAuthor Commented:
I solved the problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.