开发者

WebRequestMethods.Ftp to navigate to directory

开发者 https://www.devze.com 2023-01-11 22:59 出处:网络
I am trying to upload a file via ftp using FtpWebRequest as below: ftpRequest = (FtpWebRequest)WebRequest.Create(\"ftp.somethong.com\");

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

精彩评论

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