使用 FtpWebRequest 下载 FTP
我使用此代码通过 FTP 下载文件:
FtpWebRequest reqFTP; reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + IPServer + "/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(user, pass);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.UsePassive = false;
response = reqFTP.GetResponse();
但我有一个问题。我的凭据将创建我的用户的主文件夹。我必须返回根文件夹并选择特定文件夹来下载文件。 我如何在 Uri 中指定我需要返回?
我尝试使用这个 /../ 但不起作用...
有什么帮助吗?
I use this code to download a file by FTP:
FtpWebRequest reqFTP; reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + IPServer + "/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(user, pass);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.UsePassive = false;
response = reqFTP.GetResponse();
But I have a problem. My credentials will make my user's home folder. I must go back to the root folder and select the specific folder to download the file.
how i specified in the Uri that i need go back?
I tried to use this /../ but is not working...
Little help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与您的代码无关...
ftp 服务器决定 ftp 根文件夹是什么。
对于您的凭据,这似乎是用户的主目录。
如果您想更改它,请检查 ftp-server 文档和配置
this has nothing to do with your code ...
the ftp-server decides what's the ftp root folder.
for your credentials that seems to be that users home dir.
if you want to change that, check the ftp-server docs & config