I am trying to upload a file via ftp using FtpWebRequest as below:
ftpRequest = (FtpWebRequest)WebRequest.Create("ftp.somethong.com");
ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
ftpRequest.Credentials = new NetworkCredential("user", "pass");
However, when connected and uploaded the file goes into the root, whereas, I need for it to be p开发者_如何学JAVAut into the /Upload directory.
I can make directories but how can I browse there, before uploading the file?
You'll need to put the directory in the URL you used to create the request, i.e.
ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://ftp.somethong.com/Upload/filename.ext");
精彩评论