예제 #1
0
        /// <summary>
        /// Can be used for get file and directory item information.
        /// </summary>
        /// <param name="ftpPath"></param>
        /// <returns></returns>
        public FtpItemInfo GetItemInfo(string ftpPath)
        {
            string value  = ftpPath.TrimEnd('/');
            string parent = FtpCommon.GetParent(value);
            var    list   = GetDirectoryItems(parent);

            return(list.FirstOrDefault(q => q.FtpPath == value));
        }
예제 #2
0
        /// <summary>
        /// Only can be used for directory path, this method will return files and sub-directories that contained in ftpPath.
        /// </summary>
        /// <param name="ftpPath"></param>
        /// <returns></returns>
        public List <FtpItemInfo> GetDirectoryItems(string ftpPath)
        {
            List <FtpItemInfo> list    = new List <FtpItemInfo>();
            List <string>      details = ListDetails(ftpPath);

            foreach (string detail in details)
            {
                var fileInfo = GetItemInfoByDetail(detail);

                if (fileInfo == null)
                {
                    continue;
                }

                fileInfo.FtpPath = FtpCommon.AppendPath(ftpPath, fileInfo.Name);
                list.Add(fileInfo);
            }

            return(list);
        }