private static FileStruct ParseFromUnixStyle(string record) { FileStruct file = new FileStruct(); if (record[0] == '-' || record[0] == 'd') { char[] pars = { '\r', ' ' }; string[] tmp = record.Split(pars, StringSplitOptions.RemoveEmptyEntries); file.Flags = tmp[0]; file.IsDirectory = (file.Flags[0] == 'd'); file.Owner = tmp[2]; file.Time = string.Format("{0} {1} {2}", tmp[6], tmp[5], tmp[7]); for (int i = 8; i < tmp.Length; i++) { file.Name += tmp[i] + " "; } file.Name = file.Name.Trim(); } else file.Name = ""; return file; }
public static List<FileStruct> GetList(string dataString) { List<FileStruct> myListArray = new List<FileStruct>(); string[] dataRecords = dataString.Split('\n'); foreach (var item in dataRecords) { if (item != "") { FileStruct file = new FileStruct(); file = ParseFromUnixStyle(item); if (file.Name != "" && file.Name != "." && file.Name != "..") { myListArray.Add(file); } } } return myListArray; }