예제 #1
0
        private void ShowItemInfo(int itemIdx)
        {
            string item = directoryItems[itemIdx];

            if (item == "...")
            {
                CCommon.ShowLineInPosition(left + 1, top + height - 3, new string(' ', width - 2), ConsoleColor.DarkBlue, ConsoleColor.White);
                return;
            }

            string itemInfoLine = "";

            if (CCommon.IsDir(item))
            {
                long dirSize       = CCommon.GetFolderSizeInBytes(item);
                long numberOfFiles = CCommon.GetNumberOfFilesInFolder(item);
                itemInfoLine = $"size: {dirSize}  num of files: {numberOfFiles}";
            }

            if (CCommon.IsFile(item))
            {
                FileInfo fileInfo = new FileInfo(item);
                long     fileSize = fileInfo.Length;
                itemInfoLine = $"size: {fileSize}";
            }

            itemInfoLine = itemInfoLine.PadRight(width - 2, ' ');
            CCommon.ShowLineInPosition(left + 1, top + height - 3, itemInfoLine, ConsoleColor.DarkBlue, ConsoleColor.White);
        }
예제 #2
0
        string prepareItemLine(int idx, bool needSizeForFolder = false)
        {
            string    currentItemFullName = directoryItems[idx];
            CFileInfo fInfo = Get_File_Info(currentItemFullName);

            string name = System.IO.Path.GetFileNameWithoutExtension(fInfo.name);

            if (name.Length > 22)
            {
                name = name.Substring(0, 19) + "...";
            }
            while (name.Length < 22)
            {
                name += " ";
            }

            string ext = fInfo.extOrDir;

            if (ext.StartsWith("."))
            {
                ext = ext.Remove(0, 1);
            }
            while (ext.Length < 3)
            {
                ext += " ";
            }

            string size = fInfo.size.ToString();

            if (needSizeForFolder & CCommon.IsDir(currentItemFullName))
            {
                size = CCommon.GetFolderSizeInBytes(currentItemFullName).ToString();
            }

            return(name + " " + ext + " " + String.Format("{0,10}", size));
        }