Skip to content

Commit fc408f1

Browse files
committed
Add a try/catch around clipboard access
Clipboard is notoriously unreliable
1 parent ab39b53 commit fc408f1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/StructuredLogViewer/MainWindow.xaml.cs

+13-6
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,23 @@ private bool TryOpenFromClipboard()
203203

204204
private string GetSingleFileFromClipboard()
205205
{
206-
if (Clipboard.ContainsFileDropList())
206+
try
207207
{
208-
var fileDropList = Clipboard.GetFileDropList();
209-
if (fileDropList.Count == 1)
208+
if (Clipboard.ContainsFileDropList())
210209
{
211-
return fileDropList[0];
210+
var fileDropList = Clipboard.GetFileDropList();
211+
if (fileDropList.Count == 1)
212+
{
213+
return fileDropList[0];
214+
}
212215
}
213-
}
214216

215-
return Clipboard.GetText();
217+
return Clipboard.GetText();
218+
}
219+
catch
220+
{
221+
return null;
222+
}
216223
}
217224

218225
private void DisplayWelcomeScreen(string message = "")

0 commit comments

Comments
 (0)