Skip to content

Commit 736f278

Browse files
committed
fixed FileDialog exception;
1 parent aa51628 commit 736f278

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

System/Windows/Forms/FileDialog.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ public void SetDirectory(string path, bool addPrevPath = false)
428428
for (int i = 0; i < currentFiles.Length; i++)
429429
{
430430
var file = currentFiles[i];
431+
file.CurrentPath = currentPath;
432+
431433
var fileNode = new TreeNode(file.ToString());
432434
fileNode.Tag = file;
433435
fileNode.ImageIndex = file.IsDirectory ? 0 : 1;
@@ -514,6 +516,15 @@ protected override void OnDrawNode(DrawTreeNodeEventArgs e)
514516
if (fInfo == null)
515517
return;
516518

519+
e.Graphics.uwfDrawString(
520+
fInfo.LastWriteTime.ToString("dd.MM.yyyy HH:mm"),
521+
Font,
522+
e.Node.ForeColor,
523+
selectionBounds.X + 460,
524+
selectionBounds.Y,
525+
200,
526+
selectionBounds.Height);
527+
517528
e.Graphics.uwfDrawString(
518529
HumanizeBytes(fInfo.Length),
519530
Font,
@@ -527,12 +538,9 @@ protected override void OnDrawNode(DrawTreeNodeEventArgs e)
527538

528539
private static string HumanizeBytes(long bytes)
529540
{
530-
if (bytes < 1024)
531-
return " 1KB";
532-
if (bytes < 1024 * 1024)
533-
return (bytes / 1024) + " KB";
541+
if (bytes < 1024) return " 1 KB";
534542

535-
return "WE";
543+
return bytes / 1024 + " KB";
536544
}
537545
}
538546
}
@@ -545,16 +553,20 @@ public System.IO.FileInfo Info
545553
{
546554
get
547555
{
548-
if (info == null)
549-
info = new System.IO.FileInfo(Name);
556+
if (IsDirectory)
557+
return null;
558+
559+
if (info == null && System.IO.File.Exists(CurrentPath + Name))
560+
info = new System.IO.FileInfo(CurrentPath + Name);
550561

551562
return info;
552563
}
553564
}
554565
#endif
555-
556-
public bool IsDirectory { get; set; }
557-
public string Name { get; set; }
566+
567+
public string CurrentPath;
568+
public bool IsDirectory;
569+
public string Name;
558570

559571
public override string ToString()
560572
{

0 commit comments

Comments
 (0)