예제 #1
0
 /// <Unix�����ļ��ṹ>
 /// ��Unix��ʽ�з����ļ���Ϣ
 /// </Unix�����ļ��ṹ>
 /// <param name="Record">�ļ���Ϣ</param>
 private FileStruct ParseFileStructFromUnixStyleRecord(string Record)
 {
     FileStruct f = new FileStruct();
     string processstr = Record.Trim();
     f.Flags = processstr.Substring(0, 10);
     f.IsDirectory = (f.Flags[0] == 'd');
     processstr = (processstr.Substring(11)).Trim();
     _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);   //����һ����
     f.Owner = _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);
     f.Group = _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);
     _cutSubstringFromStringWithTrim(ref processstr, ' ', 0);   //����һ����
     string yearOrTime = processstr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2];
     if (yearOrTime.IndexOf(":") >= 0)  //time
     {
         processstr = processstr.Replace(yearOrTime, DateTime.Now.Year.ToString());
     }
     f.CreateTime = DateTime.Parse(_cutSubstringFromStringWithTrim(ref processstr, ' ', 8));
     f.Name = processstr;   //����������
     return f;
 }
예제 #2
0
 /// <windows�����ļ��ṹ>
 /// ��Windows��ʽ�з����ļ���Ϣ
 /// </windows�����ļ��ṹ>
 /// <param name="Record">�ļ���Ϣ</param>
 private FileStruct ParseFileStructFromWindowsStyleRecord(string Record)
 {
     FileStruct f = new FileStruct();
     string processstr = Record.Trim();
     string dateStr = processstr.Substring(0, 8);
     processstr = (processstr.Substring(8, processstr.Length - 8)).Trim();
     string timeStr = processstr.Substring(0, 7);
     processstr = (processstr.Substring(7, processstr.Length - 7)).Trim();
     DateTimeFormatInfo myDTFI = new CultureInfo("en-US", false).DateTimeFormat;
     myDTFI.ShortTimePattern = "t";
     f.CreateTime = DateTime.Parse(dateStr + " " + timeStr, myDTFI);
     if (processstr.Substring(0, 5) == "<DIR>")
     {
         f.IsDirectory = true;
         processstr = (processstr.Substring(5, processstr.Length - 5)).Trim();
     }
     else
     {
         string[] strs = processstr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);   // true);
         processstr = strs[1];
         f.IsDirectory = false;
     }
     f.Name = processstr;
     return f;
 }
예제 #3
0
 /// <summary>
 /// ����ļ���Ŀ¼�б�
 /// </summary>
 /// <param name="datastring">FTP���ص��б��ַ���Ϣ</param>
 private FileStruct[] GetList(string[] dataRecords)
 {
     List<FileStruct> myListArray = new List<FileStruct>();
     FileListStyle _directoryListStyle = GuessFileListStyle(dataRecords);
     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();
 }