/// <summary> /// 获得文件和目录列表 /// </summary> /// <param name="datastring">FTP返回的列表字符信息</param> private FileStruct[] GetList(string datastring) { List <FileStruct> myListArray = new List <FileStruct>(); string[] tmpdataRecords = datastring.Split('\n'); FileListStyle _directoryListStyle = GuessFileListStyle(tmpdataRecords); List <string> dataRecords = tmpdataRecords.ToList(); if (dataRecords[0].IndexOf("total") >= 0) { dataRecords.RemoveAt(0); } foreach (string s in dataRecords) { if (_directoryListStyle != FileListStyle.Unknown && s != "") { FileStruct f = new FileStruct(); f.Name = ".."; switch (_directoryListStyle) { case FileListStyle.UnixStyle: f = ParseFileStructFromUnixStyleRecord(s); break; case FileListStyle.WindowsStyle: f = ParseFileStructFromWindowsStyleRecord(s); break; } if (!(f.Name == "." || f.Name == "..")) { myListArray.Add(f); } } } return(myListArray.ToArray()); }