How to use WebClient to FTP Uploadfile to the Root directory of the FTP Server?

  • Thread starter Thread starter MrAvgProgrammer
  • Start date Start date
M

MrAvgProgrammer

Guest
I have not bee able to figure this one out for a few days.


I have a FTP server which when the User logs in they are immediately placed in their "pickup folder". This is how the Host is configured. ie: ftp:\\ftp.mysite.com\USERNAME\

I need to be able to upload to ftp:\\ftp.mysite.com\UPLOAD

The FTP user has access to ftp:\\ftp.mysite.com and ftp:\\ftp.mysite.com\UPLOAD So I am certain it is not a permission thing. I also know it works because I can navigate to this folder via Internet Explorer and FileZilla interfaces.

Basically I need to be able to perform a "CD.." (or something like this) So that I can go to the FTP ROOT directory to perform my upload.
I currently get a 550 Error because it is looking for ftp:\\ftp.mysite.com\UPLOAD, which that directory do not exist on the initial user login.


Try
Dim FTPUpReq As FtpWebRequest = WebRequest.Create("ftp://" & ftpuri & "/../UPLOAD/")
FTPUpReq.Credentials = New Net.NetworkCredential(ftpusername, ftppassword)
FTPUpReq.Method = WebRequestMethods.Ftp.UploadFile
Using ftpClient As New WebClient()
ftpClient.Credentials = New System.Net.NetworkCredential(ftpusername, ftppassword)
ftpClient.UploadFile("ftp://" & ftpuri & "/UPLOAD/test.txt", strFullLocalFilePath2Upload)
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try

Continue reading...
 
Back
Top