开发者

WebRequestMethods.Ftp to navigate to directory

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜