Esempio n. 1
0
        /// <summary>
        /// 从Unix格式中返回文件信息

        /// </summary>
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private FileStruct[] GetFileList(string path)
        {
            try
            {
                Uri          ftpUei  = new Uri(_ftpServerIp + path);
                clsFTP       cf      = new clsFTP(ftpUei, _ftpUserID, _ftpPassword);
                FileStruct[] filestr = cf.ListFiles();

                string       dbNameTxt = _errorAddress + @"\GetFile" + DateTime.Now.ToLongDateString() + ".txt";
                StreamWriter stream    = new StreamWriter(dbNameTxt, true);
                stream.WriteLine("获取文件成功。" + "文件个数为:" + filestr.Length + "时间:)" + DateTime.Now.ToString());
                stream.Close();
                return(filestr);
            }
            catch (Exception ex)
            {
                string       dbNameTxt = _errorAddress + @"\ErrorGetFile" + DateTime.Now.ToLongDateString() + ".txt";
                StreamWriter stream    = new StreamWriter(dbNameTxt, true);
                stream.WriteLine("获取文件失败。异常为:" + ex.Message + "时间:)" + DateTime.Now.ToString());
                stream.Close();
                FileStruct[] filestr = new FileStruct[0];
                return(filestr);
            }
        }