コード例 #1
0
ファイル: DiagnosticsForm.cs プロジェクト: zuokaihuang/PTVS
        private void _save_Click(object sender, EventArgs e)
        {
            var path = _provider.BrowseForFileSave(
                Handle,
                "Text Files (*.txt)|*.txt|All Files (*.*)|*.*",
                PathUtils.GetAbsoluteFilePath(
                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                    string.Format("Diagnostic Info {0:yyyy-MM-dd'T'HHmmss}.txt", DateTime.Now)
                    )
                );

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            try {
                TaskDialog.CallWithRetry(
                    _ => File.WriteAllText(path, _textBox.Text),
                    _provider,
                    Strings.ProductTitle,
                    Strings.FailedToSaveDiagnosticInfo,
                    Strings.ErrorDetail,
                    Strings.Retry,
                    Strings.Cancel
                    );

                Process.Start("explorer.exe", "/select," + ProcessOutput.QuoteSingleArgument(path));
            } catch (OperationCanceledException) {
            }
        }
コード例 #2
0
        private void Save_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var path = _provider.BrowseForFileSave(
                new WindowInteropHelper(this).Handle,
                Strings.DiagnosticsWindow_TextFileFilter,
                PathUtils.GetAbsoluteFilePath(
                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                    Strings.DiagnosticsWindow_DefaultFileName.FormatUI(DateTime.Now)
                    )
                );

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            try {
                TaskDialog.CallWithRetry(
                    _ => File.WriteAllText(path, _info.Result),
                    _provider,
                    Strings.ProductTitle,
                    Strings.FailedToSaveDiagnosticInfo,
                    Strings.ErrorDetail,
                    Strings.Retry,
                    Strings.Cancel
                    );

                Process.Start("explorer.exe", "/select," + ProcessOutput.QuoteSingleArgument(path)).Dispose();
            } catch (OperationCanceledException) {
            }
        }