Esempio n. 1
0
        /// <summary>
        /// 获得当前文件夹下的所有文件(仅文件)
        /// </summary>
        /// <returns></returns>
        public List <string> GetAllFiles()
        {
            //返回值
            List <string> result = new List <string>();;
            //先得到此文件夹下的所有信息
            List <FileStruct> allList = this.GetList();
            //循环选出文件夹
            FileStruct fs = new FileStruct();

            for (int i = 0; i < allList.Count; i++)
            {
                fs = allList[i];
                if (fs.FileType != "文件夹")
                {
                    result.Add(fs.Name);
                }
            }
            return(result);
        }
Esempio n. 2
0
        private FileStruct ParseFileStructFromUnixStyleRecord(string record)
        {
            ///Assuming record style as
            /// dr-xr-xr-x   1 owner    group               0 Nov 25  2002 bussys
            FileStruct f = new FileStruct();

            if (record[0] == '-' || record[0] == 'd')
            {// its a valid file record
                string processstr = record.Trim();
                f.Flags       = processstr.Substring(0, 9);
                f.IsDirectory = (f.Flags[0] == 'd');
                processstr    = (processstr.Substring(11)).Trim();
                _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);   //skip one part
                f.Owner      = _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);
                f.CreateTime = getCreateTimeString(record);
                int fileNameIndex = record.IndexOf(f.CreateTime) + f.CreateTime.Length;
                f.Name = record.Substring(fileNameIndex).Trim();   //Rest of the part is name
            }
            else
            {
                f.Name = "";
            }
            return(f);
        }