static int CompareFileAttributes(FileSystemInfo a, FileSystemInfo b) { var x = ShellInfoItem.GetFileAttributesString(a.Attributes); var y = ShellInfoItem.GetFileAttributesString(b.Attributes); return(x.CompareTo(y)); }
void SetStorageStatus(DriveInfo drive) { string volumnName = string.IsNullOrEmpty(drive.VolumeLabel) ? NavigationPane.GetDriveType(drive.DriveType) : drive.VolumeLabel; lblTopStorageStatus.Text = String.Format( "[{0}] {1} free in {2}", volumnName, ShellInfoItem.GetBytesReadable(drive.TotalFreeSpace), ShellInfoItem.GetBytesReadable(drive.TotalSize)); }
private static ListViewItem InitListviewItem(FileSystemInfo info) { var list = SmallImageList; var item = new ShellInfoItem(info); string[] row = item.ToArray(); int key = list.Images.IndexOfKey("unknown"); if (info.Attributes.HasFlag(FileAttributes.Directory)) { var dir = (DirectoryInfo)info; try { dir.GetAccessControl(); if (dir.Attributes.HasFlag(FileAttributes.Hidden)) { key = list.Images.IndexOfKey("hidden_folder"); } else { key = list.Images.IndexOfKey("FolderIcon"); } } catch (UnauthorizedAccessException) { //key = list.Images.IndexOfKey("locked_folder"); key = list.Images.IndexOfKey("LockFolder"); } } else { var icon = ShellIcon.GetIcon(info.FullName); string ext = item.Ext; if (icon != null) { AddKeyToImageList(info.FullName, icon); key = list.Images.IndexOfKey(info.FullName); } else if (!String.IsNullOrEmpty(ext)) { icon = ShellIcon.GetSmallIconFromExtension(ext); AddKeyToImageList(ext, icon); key = list.Images.IndexOfKey(ext); } } var lvi = new ListViewItem(row, key) { Tag = info.FullName }; return(lvi); }