Esempio n. 1
0
        /// <summary>
        /// path_name must be /-ended
        /// </summary>
        /// <param name="path_name"></param>
        /// <returns></returns>
        public List <FtpEntryInfo> GetDirectoryDetailsList(string path_name, bool force_update)
        {
            StreamReader        s_reader = null;
            List <FtpEntryInfo> ret      = new List <FtpEntryInfo>();
            FtpWebRequest       req      = null;
            FtpWebResponse      resp     = null;

            if (!force_update)
            {
                force_update = !cache_retrieve(path_name, ret);
            }

            if (force_update)
            {
                try
                {
                    req        = create_request(path_name);
                    req.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                    resp       = (FtpWebResponse)req.GetResponse();

                    s_reader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
                    string line = string.Empty;
                    while ((line = s_reader.ReadLine()) != null)
                    {
                        FtpEntryInfo entry = FtpEntryInfo.FromDetailedListLine(line, path_name);
                        ret.Add(entry);
                    }
                    //update cache
                    cache_update(path_name, ret);
                }
                finally
                {
                    if (resp != null)
                    {
                        resp.Close();
                    }
                }
            }

            return(ret);
        }