Read File from FTP location in Console Application using C#

Category: C#.Net Comments: No comments

Today I’m going to tell you to read text from FTP Location.Please follow below steps to fetch

Step 1 :-  Place code in Class file

WebRequest request = WebRequest.Create(ConfigurationManager.AppSettings["FTPPath"]);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["FTPUserName"],
using (var responde = (FtpWebResponse)request.GetResponse())
Stream responseStream = responde.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
ftpDownloadResult = reader.ReadToEnd().Trim();

Step 2:- Add credential in config Section

<add key=”FTPPath” value=””></add>
<add key=”FTPUserName” value=”USERNAME” />
<add key=”FTPPassword” value=”PASSWORD” />

<defaultProxy useDefaultCredentials=”true”>
<proxy autoDetect=”True”/>


Leave a Reply

Your email address will not be published. Required fields are marked *


HTML tags are not allowed.