public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Get the full path var path = (string)value; // If the path is null, ignore if (path == null) { return(null); } // Get the name of the file/folder var name = MainWindow.GetFileFolderName(path); // By Default, we presume an image var image = "img/file.png"; // If the name is blank, we presume it's a drive as we cannot have a blank file or folder name if (string.IsNullOrEmpty(name)) { image = "img/drive.png"; } else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory)) { image = "img/folder-closed.png"; } return(new BitmapImage(new Uri($"pack://application:,,,/{image}"))); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var path = (string)value; if (path == null) { return(null); } var name = MainWindow.GetFileFolderName(path); var image = "Images/file.png"; // If name is blank, we presume that it's drive if (string.IsNullOrEmpty(name)) { image = "Images/drive.png"; } else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory)) { image = "Images/folder.png"; } return(new BitmapImage(new Uri($"pack://application:,,,/{image}"))); }