示例#1
0
文件: FtpHelper.cs 项目: yqMac/School
        private ServerFileData ParseUnixDirLine(string fileLine)
        {
            ServerFileData serverData = new ServerFileData();
            string[] fileInfo = new string[8];
            int index = 0;
            int position;

            position = fileLine.IndexOf(' ');
            while (index < fileInfo.Length)
            {
                fileInfo[index] = fileLine.Substring(0, position);
                fileLine = fileLine.Substring(position);
                fileLine = fileLine.Trim();
                index++;
                position = fileLine.IndexOf(' ');
            }
            serverData.fileName = fileLine;
            serverData.permission = fileInfo[0];
            serverData.owner = fileInfo[2];
            serverData.group = fileInfo[3];
            try
            {
                serverData.size = Convert.ToInt32(fileInfo[4]);
            }
            catch
            {

            }

            serverData.date = fileInfo[5] + ' ' + fileInfo[6] + ' ' + fileInfo[7];
            serverData.isDirectory = serverData.permission[0] == 'd';

            return serverData;
        }
示例#2
0
文件: FtpHelper.cs 项目: yqMac/School
        //
        //Prase the Dos file Line infor
        //
        private ServerFileData PraseDosDirLine(string fileLine)
        {
            ServerFileData serverData = new ServerFileData();
            try
            {
                
                string[] fileInfo = new string[3];
                int index = 0;
                int pos = 0;
                pos = fileLine.IndexOf(' ');
                while (index < fileInfo.Length)
                {
                    fileInfo[index] = fileLine.Substring(0, pos);
                    fileLine = fileLine.Substring(pos);
                    fileLine = fileLine.Trim();
                    index++;
                    pos = fileLine.IndexOf(' ');
                }

                serverData.fileName = fileLine;
                if (fileInfo[2] != "<DIR>")
                {
                    serverData.size = Convert.ToInt32(fileInfo[2]);
                }
                serverData.date = fileInfo[0] + " " + fileInfo[1];
                serverData.isDirectory = fileInfo[2] == "<DIR>";

                return serverData;
            }
            catch
            {
                serverData = null;
                return serverData;
            }
        }