Download FTP using FtpWebRequest
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开发者_Go百科 tried to use this /../ but is not working...
Little help?
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
精彩评论