소스 검색

Catching and ignoring exception when outlook keeps files open in document window

Kenric Nugteren 1 년 전
부모
커밋
75be707008
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      inabox.wpf/DynamicGrid/DynamicDocumentGrid.cs

+ 8 - 1
inabox.wpf/DynamicGrid/DynamicDocumentGrid.cs

@@ -295,7 +295,14 @@ namespace InABox.DynamicGrid
                     Task.Run(() =>
                     {
                         var tempfile = Path.Combine(System.IO.Path.GetTempPath(), SanitiseFileName(file.Key));
-                        File.WriteAllBytes(tempfile, file.Value);
+                        try
+                        {
+                            File.WriteAllBytes(tempfile, file.Value);
+                        }
+                        catch
+                        {
+                            // Outlook likes to keep files open apparently, which breaks this code.
+                        }
                         var info = new System.Diagnostics.ProcessStartInfo(tempfile);
                         info.UseShellExecute = true;
                         info.Verb = "Open";