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
Niranjan Poddar
1.1k
648
96.3k
Get Files from a Remote Server using ftp.
Jun 6 2016 8:22 AM
Dear all,
Please help me how to get all files name from remote server using ftp.
I have already used but getting error:
public List<string> GetFileList()
{
System.Net.FtpWebRequest ftpRequest = (System.Net.FtpWebRequest)System.Net.WebRequest.Create("ftp://ftpserver.com");
ftpRequest.Credentials = new System.Net.NetworkCredential("username", "password");
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
System.Net.FtpWebResponse response = (System.Net.FtpWebResponse)ftpRequest.GetResponse();
System.IO.StreamReader streamReader = new System.IO.StreamReader(response.GetResponseStream());
List<string> directories = new List<string>();
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
directories.Add(line);
line = streamReader.ReadLine();
}
streamReader.Close();
return directories;
}
Error: The remote server returned an error: (500) Internal Server Error.
Thanks & Regards
Niranjan Poddar
Reply
Answers (
1
)
making a chat application
Retain data after postback in mvc3