mpdillon
asked on
VB.net FTP error - The remote server returned an error: File Unavailable...
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.
Thanks,
pat
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.
Thanks,
pat
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)
stream.Close()
stream.Dispose()
'- Handle response here if you'd like ...
'Dim response As FtpWebResponse = request.GetResponse()
'response.Close()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
FTP upload is working with new code
Glad you got it working :)
ASKER
Doesn't sound silly at all. More often than not I usually mess something up that is very simple and just taken for granted. In this case however, the user name and password were correct.
I found a solution by using slightly differnt code. The code below is working for me.
Thanks,
pat
Open in new window