troubleshooting Question FTP error - The remote server returned an error: File Unavailable...

Avatar of mpdillon
mpdillon asked on
Visual Basic.NET
4 Comments1 Solution840 ViewsLast Modified:
In the following code I am trying to upload a file to a server. The code runs up until the line I have highlighted with ****>>>>. The line begins Dim Stream...
The error states:
The remote server returned an error:(550) File Unavailable(e.g. File not found, no access.)

I do not believe the error is due to access. Using the FTP client Core-Lite, I am able to upload a file to the directory.

What do I need to change to upload a file.


Public Sub FTPUploadFile(ByVal localfile As String, ByVal remotefile As String)
        '- Create request
        Dim request As FtpWebRequest = WebRequest.Create("ftp://" & PublicVariables.FTPClientIDStringP & "/" & remotefile)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.Credentials = New NetworkCredential(PublicVariables.FTPUserNameStringP, PublicVariables.FTPPasswordStringP)
        request.UsePassive = True
        request.UseBinary = True
        request.KeepAlive = False

        '- Upload file
        Dim fileContents As Byte() = System.IO.File.ReadAllBytes(localfile)
***>>> Error Here   Dim stream As System.IO.Stream = request.GetRequestStream()  <<<******
        stream.Write(fileContents, 0, fileContents.Length)

        '- Handle response here if you'd like ...
        'Dim response As FtpWebResponse = request.GetResponse()
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros