コード例 #1
0
        protected string BuildLongReply(string [] asFiles)
        {
            string sDirectory = this.GetPath(string.Empty);

            var stringBuilder = new StringBuilder();

            for (int nIndex = 0; nIndex < asFiles.Length; nIndex++)
            {
                string sFile = asFiles[nIndex];
                sFile = Path.Combine(sDirectory, sFile);

                IFileInfo info = this.ConnectionObject.FileSystemObject.GetFileInfo(sFile);

                if (info != null)
                {
                    string sAttributes = info.GetAttributeString();
                    stringBuilder.Append(sAttributes);
                    stringBuilder.Append(" 1 owner group");

                    if (info.IsDirectory())
                    {
                        stringBuilder.Append("            1 ");
                    }
                    else
                    {
                        string sFileSize = info.GetSize().ToString();
                        stringBuilder.Append(General.TextHelpers.RightAlignString(sFileSize, 13, ' '));
                        stringBuilder.Append(" ");
                    }

                    DateTime fileDate = info.GetModifiedTime();

                    string sDay = fileDate.Day.ToString();

                    stringBuilder.Append(TextHelpers.Month(fileDate.Month));
                    stringBuilder.Append(" ");

                    if (sDay.Length == 1)
                    {
                        stringBuilder.Append(" ");
                    }

                    stringBuilder.Append(sDay);
                    stringBuilder.Append(" ");
                    stringBuilder.Append(string.Format("{0:hh}", fileDate));
                    stringBuilder.Append(":");
                    stringBuilder.Append(string.Format("{0:mm}", fileDate));
                    stringBuilder.Append(" ");

                    stringBuilder.Append(asFiles[nIndex]);
                    stringBuilder.Append("\r\n");
                }
            }

            return(stringBuilder.ToString());
        }
コード例 #2
0
        protected override string OnProcess(string sMessage)
        {
            string sFile = GetPath(sMessage);

            ConnectionObject.FileToRename = sFile;

            IFileInfo info = ConnectionObject.FileSystemObject.GetFileInfo(sFile);

            if (info == null)
            {
                return(GetMessage(550, string.Format("File does not exist ({0}).", sFile)));
            }

            ConnectionObject.RenameDirectory = info.IsDirectory();
            return(GetMessage(350, string.Format("Rename file started ({0}).", sFile)));
        }
コード例 #3
0
        protected string GenerateEntry(IFileInfo info)
        {
            StringBuilder entry = new StringBuilder();

            bool isDirectory = info.IsDirectory();

            if (isDirectory)
            {
                entry.Append("Type=dir; ");
                string dirName = FileNameHelpers.GetDirectoryName(info.Path());
                entry.Append(dirName);
            }
            else
            {
                entry.Append(string.Format("Type=file;Size={0};Modify={1}; ", info.GetSize(), info.GetModifiedTime().ToString("yyyyMMddHHmmss")));
                entry.Append(FileNameHelpers.GetFileName(info.Path()));
            }

            return entry.ToString();
        }
コード例 #4
0
        protected string GenerateEntry(IFileInfo info)
        {
            StringBuilder entry = new StringBuilder();

            bool isDirectory = info.IsDirectory();

            if (isDirectory)
            {
                entry.Append("Type=dir; ");
                string dirName = FileNameHelpers.GetDirectoryName(info.Path());
                entry.Append(dirName);
            }
            else
            {
                entry.Append(string.Format("Type=file;Size={0};Modify={1}; ", info.GetSize(), info.GetModifiedTime().ToString("yyyyMMddHHmmss")));
                entry.Append(FileNameHelpers.GetFileName(info.Path()));
            }

            return(entry.ToString());
        }
コード例 #5
0
        private string GetLongProperty(IFileInfo info)
        {
            if (info == null)
                return null;

            var stringBuilder = new StringBuilder();

            // permissions
            string sAttributes = info.GetAttributeString();
            stringBuilder.Append(sAttributes);
            stringBuilder.Append(" 1 owner group");

            // check whether info is directory
            bool isDirectory = info.IsDirectory();

            // size
            string sFileSize = info.GetSize().ToString(); // if info is directory, the size will be 1
            stringBuilder.Append(TextHelpers.RightAlignString(sFileSize, 13, ' '));
            stringBuilder.Append(" ");

            // modify time
            DateTimeOffset fileDate = info.GetModifiedTime(); //if info is directory, the modify time will be the current time
            // month
            stringBuilder.Append(TextHelpers.Month(fileDate.Month));
            stringBuilder.Append(" ");
            // day
            string sDay = fileDate.Day.ToString();
            if (sDay.Length == 1)
                stringBuilder.Append(" ");
            stringBuilder.Append(sDay);
            stringBuilder.Append(" ");
            // year or hour:min
            if (fileDate.Year < DateTime.Now.Year)
            {
                stringBuilder.Append(" " + fileDate.Year);
            }
            else
            {
                stringBuilder.Append(string.Format("{0:hh}:{1:mm}", fileDate, fileDate));
            }
            stringBuilder.Append(" ");

            // filename
            string path = info.Path();
            if (isDirectory)
                stringBuilder.Append(FileNameHelpers.GetDirectoryName(path));
            else
                stringBuilder.Append(FileNameHelpers.GetFileName(path));

            // end
            stringBuilder.Append("\r\n");

            return stringBuilder.ToString();
        }
コード例 #6
0
        private string GetLongProperty(IFileInfo info)
        {
            if (info == null)
            {
                return(null);
            }

            var stringBuilder = new StringBuilder();

            // permissions
            string sAttributes = info.GetAttributeString();

            stringBuilder.Append(sAttributes);
            stringBuilder.Append(" 1 owner group");

            // check whether info is directory
            bool isDirectory = info.IsDirectory();

            // size
            string sFileSize = info.GetSize().ToString(); // if info is directory, the size will be 1

            stringBuilder.Append(TextHelpers.RightAlignString(sFileSize, 13, ' '));
            stringBuilder.Append(" ");

            // modify time
            DateTimeOffset fileDate = info.GetModifiedTime(); //if info is directory, the modify time will be the current time

            // month
            stringBuilder.Append(TextHelpers.Month(fileDate.Month));
            stringBuilder.Append(" ");
            // day
            string sDay = fileDate.Day.ToString();

            if (sDay.Length == 1)
            {
                stringBuilder.Append(" ");
            }
            stringBuilder.Append(sDay);
            stringBuilder.Append(" ");
            // year or hour:min
            if (fileDate.Year < DateTime.Now.Year)
            {
                stringBuilder.Append(" " + fileDate.Year);
            }
            else
            {
                stringBuilder.Append(string.Format("{0:hh}:{1:mm}", fileDate, fileDate));
            }
            stringBuilder.Append(" ");

            // filename
            string path = info.Path();

            if (isDirectory)
            {
                stringBuilder.Append(FileNameHelpers.GetDirectoryName(path));
            }
            else
            {
                stringBuilder.Append(FileNameHelpers.GetFileName(path));
            }

            // end
            stringBuilder.Append("\r\n");

            return(stringBuilder.ToString());
        }