private void LoadDirectory(string path) { currentDirectory = path; FillDirectories(currentDirectory); List <FtpItem> list = FTPAdapter.GetDirList(currentDirectory). OrderBy(x => x.ItemType != FtpItemType.Directory).ThenBy(x => x.Name).ToList(); list.Insert(0, new FtpItem("..", DateTime.Now, 0, null, null, FtpItemType.Unknown, null)); lvFTPList.Items.Clear(); lvFTPList.SmallImageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; foreach (FtpItem file in list) { if (file.ItemType == FtpItemType.Directory && (file.Name == "." || file.Name == "..")) { continue; } ListViewItem lvi = new ListViewItem(file.Name); lvi.Tag = file; if (file.ItemType != FtpItemType.Unknown) { if (file.ItemType == FtpItemType.File) { lvi.SubItems.Add(file.Size.ToString("N0")); } else { lvi.SubItems.Add(string.Empty); } lvi.SubItems.Add(IconReader.GetDisplayName(file.Name, file.ItemType == FtpItemType.Directory)); lvi.SubItems.Add(file.Modified.ToLocalTime().ToString()); lvi.SubItems.Add(file.Attributes); } string ext; if (file.ItemType == FtpItemType.Directory || file.ItemType == FtpItemType.Unknown) { ext = "Directory"; } else if (Path.HasExtension(file.Name)) { ext = Path.GetExtension(file.Name); } else { ext = "File"; } if (!lvFTPList.SmallImageList.Images.Keys.Contains(ext)) { Icon icon; if (ext == "Directory") { icon = IconReader.GetFolderIcon(IconReader.IconSize.Small, IconReader.FolderType.Closed); } else { icon = IconReader.GetFileIcon(ext, IconReader.IconSize.Small, false); } if (icon != null) { lvFTPList.SmallImageList.Images.Add(ext, icon.ToBitmap()); } } if (lvFTPList.SmallImageList.Images.Keys.Contains(ext)) { lvi.ImageKey = ext; } lvFTPList.Items.Add(lvi); } CheckFiles(false); }