public static FileInfo?GetFileInfo([NotNull] this OpenFileDialog dialog) { var file = dialog.GetFileName(); return(string.IsNullOrWhiteSpace(file) ? null : new FileInfo(file)); }