TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Demir Acar
NA
98
25.3k
how to download ftp files to client directory
Jun 8 2015 6:13 PM
I have a webproject that run on hosting company , I need to download ftp files to client directory ,my sample code like below ;
I think path isn't correct , How CAN I do .
string ftp = "ftp://ftp.adress.com/";
string filepath = "d:\\LEM";
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftp+fileName));
reqFTP.Credentials = new NetworkCredential("username","password");
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Proxy = null;
reqFTP.UsePassive = false;
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream responseStream = response.GetResponseStream();
//string filePath = (Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName));
FileStream writeStream = new FileStream(filepath + "\\" + fileName, FileMode.Create);
int Length = 2048;
Byte[] buffer = new Byte[Length];
int bytesRead = responseStream.Read(buffer, 0, Length);
while (bytesRead > 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = responseStream.Read(buffer, 0, Length);
}
writeStream.Close();
response.Close();
}
Reply
Answers (
2
)
ASP.NET creating a website
Twilio is not making call