Answered by:
How to Download Files From Server Using FTP C#?

Question
-
User-1148373670 posted
HI All,
My Scenario is to download the files from Server using FTP with below conditions.
1. Download the file based on hour basis(Each hour same new file is coming on the server and I want to read only those files not all files). Means Read the files based on Modified time for yesterday as well today date not based on file names.
Please somebody provide some code snip for this scenario to solve my issue.
Thanks In Advance
Monday, September 29, 2014 7:52 AM
Answers
-
User-158764254 posted
But I am getting exception "The requested FTP command is not supported when using HTTP proxy"A fairly common solution to that error is to set the Proxy property of your FtpWebRequest to null before you call GetResponse.
... webRequest.KeepAlive = false; webRequest.Proxy = null; FtpWebResponse webResponse = (FtpWebResponse)webRequest.GetResponse();
Give that a try and see if your error clears.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, September 29, 2014 9:02 PM
All replies
-
User-821857111 posted
You need to use the FtpWebRequest class.
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest(v=vs.110).aspx
Monday, September 29, 2014 7:55 AM -
User-1148373670 posted
Hi
I am using below code
FtpWebRequest webRequest = (FtpWebRequest)FtpWebRequest.Create(downloadFileName);
webRequest.Method = WebRequestMethods.Ftp.DownloadFile;
webRequest.Credentials = new NetworkCredential(userName.Trim(), password.Trim());
webRequest.UsePassive = true;
webRequest.UseBinary = true;
webRequest.KeepAlive = false;FtpWebResponse webResponse = (FtpWebResponse)webRequest.GetResponse();
But I am getting exception "The requested FTP command is not supported when using HTTP proxy"
Please help me.
Thanks in advance
Monday, September 29, 2014 8:34 AM -
User-158764254 posted
But I am getting exception "The requested FTP command is not supported when using HTTP proxy"A fairly common solution to that error is to set the Proxy property of your FtpWebRequest to null before you call GetResponse.
... webRequest.KeepAlive = false; webRequest.Proxy = null; FtpWebResponse webResponse = (FtpWebResponse)webRequest.GetResponse();
Give that a try and see if your error clears.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, September 29, 2014 9:02 PM