0

I am trying to list all the files and its last modified date to a C# gridview control from the folder in an ftp server. But When I try to read the folder path , the last modified date of the file name is being showed inconsistanly . How can I list the all the files and its last modified date?. Now the result is showed as given below. How can I split the date part and file name part as seperate string into an another string array from lines1 variable

 -rw-r--r-- 1 ftp ftp       0 Apr 19 21:35 40D3AECB16EEFC_Export_19042022_213529.csv
-rw-r--r-- 1 ftp ftp         144993 Apr 21 21:44 40D3AECB16EEFC_Export_21042022_214440.csv

Here is my code

 var req = CreateRequest(folderpath, WebRequestMethods.Ftp.ListDirectory);
                var req1 = CreateRequest(folderpath, WebRequestMethods.Ftp.ListDirectoryDetails);
                FtpWebResponse response = req1.GetResponse() as FtpWebResponse;
                StreamReader directoryReader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.ASCII);
                string[] lines1 = directoryReader.ReadToEnd().Split(Environment.NewLine.ToCharArray(),  

private WebRequest CreateRequest(string path, string method)
        {
            WebRequest req = null;
            try
            {
                Console.WriteLine(path);
                req = WebRequest.Create(_host + path);
                req.Method = method;
                req.Credentials = _credentials;
            }
            catch(Exception ex)
            {

            }
                return req;     
        }

0 Answers0