Skip to content

Commit b0e5e99

Browse files
committed
Also catch errors when dragging in paths
1 parent c906a7c commit b0e5e99

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

WindowsPathEditor/MainWindow.xaml.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,21 @@ private void Clean_Click(object sender, RoutedEventArgs e)
242242
get
243243
{
244244
return data => {
245-
var d = data as System.Windows.DataObject;
246-
if (d == null || !d.ContainsFileDropList() || d.GetFileDropList().Count == 0) return null;
247-
248-
var path = d.GetFileDropList()[0];
249-
if (File.Exists(path)) path = System.IO.Path.GetDirectoryName(path);
250-
251-
return new AnnotatedPathEntry(PathEntry.FromFilePath(path));
245+
string path = "...";
246+
try
247+
{
248+
var d = data as System.Windows.DataObject;
249+
if (d == null || !d.ContainsFileDropList() || d.GetFileDropList().Count == 0) return null;
250+
251+
path = d.GetFileDropList()[0];
252+
if (File.Exists(path)) path = System.IO.Path.GetDirectoryName(path);
253+
254+
return new AnnotatedPathEntry(PathEntry.FromFilePath(path));
255+
}
256+
catch (Exception ex)
257+
{
258+
return new AnnotatedPathEntry(new PathEntry(string.Format("error dragging in {0}: {1}", path, ex.Message)));
259+
}
252260
};
253261
}
254262
}

0 commit comments

Comments
 (0)