I have folder name XYZ into ftp server [ftp://ftp00.abcd.net] . I have some xml files into XYZ folder like Lggggg.XML .I want to download multiple files with same name like Lgggg.XML. Now I can download only file that's why I want to know count of files [Lgggg.XML] then I will run download file code within for loop. I want to count those xml files which exists into ftp://ftp00.abcd.net/XYZ . I searched through net but I didn't find proper solution . Any information regarding this will be helpful . Please help .
EDIT My C# code
FtpWebRequest ftpwebrequest = (FtpWebRequest)WebRequest.Create("ftp://ftp00.abcd.net/XYZ");
ftpwebrequest.Credentials = new NetworkCredential("username", "pwd");
ftpwebrequest.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)ftpwebrequest.GetResponse();
Console.WriteLine("user looged in");
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
var list = Directory.GetFiles("vit-gent-maid", "*.XML");
int count = list.Length;
Console.WriteLine("count :" + count);
using (WebClient ftpClient = new WebClient())
{
ftpClient.Credentials = new System.Net.NetworkCredential("username", "pwd");
ftpClient.DownloadFile("ftp://ftp00.abcd.net/XYZ/Lggggg.XML", @"C:\\Temp\XML\Lggggg.XML");
Console.WriteLine("file transfer successful");
}
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}