private void SaveToFile(bool includeAnalysisLogs) { string initialPath = null; try { initialPath = PathUtils.GetAbsoluteFilePath( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Strings.DiagnosticsWindow_DefaultFileName.FormatUI(DateTime.Now) ); } catch (Exception ex) when(!ex.IsCriticalException()) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); } var path = Site.BrowseForFileSave( _window.Handle, Strings.DiagnosticsWindow_TextFileFilter, initialPath ); if (string.IsNullOrEmpty(path)) { return; } Cursor.Current = Cursors.WaitCursor; try { try { TaskDialog.CallWithRetry( _ => { using (var log = new StreamWriter(path, false, new UTF8Encoding(false))) { PyService.GetDiagnosticsLog(log, includeAnalysisLogs); } }, Site, Strings.ProductTitle, Strings.FailedToSaveDiagnosticInfo, Strings.ErrorDetail, Strings.Retry, Strings.Cancel ); if (File.Exists(path)) { Process.Start( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"), "/select," + ProcessOutput.QuoteSingleArgument(path) )?.Dispose(); } } catch (OperationCanceledException) { } } finally { Cursor.Current = Cursors.Arrow; } }
private void CopyToClipboard(bool includeAnalysisLogs) { Cursor.Current = Cursors.WaitCursor; try { var log = PyService.GetDiagnosticsLog(includeAnalysisLogs); Clipboard.SetText(log, TextDataFormat.Text); } finally { Cursor.Current = Cursors.Arrow; } MessageBox.Show(Strings.DiagnosticsLogCopiedToClipboard, Strings.ProductTitle); }
private void SaveToFile(bool includeAnalysisLogs) { var path = PyService.Site.BrowseForFileSave( _window.Handle, Strings.DiagnosticsWindow_TextFileFilter, PathUtils.GetAbsoluteFilePath( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Strings.DiagnosticsWindow_DefaultFileName.FormatUI(DateTime.Now) ) ); if (string.IsNullOrEmpty(path)) { return; } Cursor.Current = Cursors.WaitCursor; try { try { var log = PyService.GetDiagnosticsLog(includeAnalysisLogs); TaskDialog.CallWithRetry( _ => File.WriteAllText(path, log), PyService.Site, Strings.ProductTitle, Strings.FailedToSaveDiagnosticInfo, Strings.ErrorDetail, Strings.Retry, Strings.Cancel ); Process.Start("explorer.exe", "/select," + ProcessOutput.QuoteSingleArgument(path)).Dispose(); } catch (OperationCanceledException) { } } finally { Cursor.Current = Cursors.Arrow; } }