当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Win32.SaveFileDialog.ShowDialog方法代码示例

本文整理汇总了C#中Microsoft.Win32.SaveFileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Win32.SaveFileDialog.ShowDialog方法的具体用法?C# Microsoft.Win32.SaveFileDialog.ShowDialog怎么用?C# Microsoft.Win32.SaveFileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Win32.SaveFileDialog的用法示例。


在下文中一共展示了Microsoft.Win32.SaveFileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportData

        public static bool ExportData()
        {

            // Configure save file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "SearchData"; // Default file name
            dlg.DefaultExt = ".txt"; // Default file extension
            dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension 

            // Show save file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process save file dialog box results 
            if (result == true)
            {
                // Save document 
                string filename = dlg.FileName;
                using (StreamWriter sw = new StreamWriter(filename))
                {
                    sw.WriteLine("[" + comboIndex + "] " + commName);
                    sw.WriteLine();
                    sw.WriteLine("\t" + perCapitaIncome);
                    sw.WriteLine("\t" + hardshipIndex);
                    sw.WriteLine("\t" + crimesName);

                    foreach (Database.CrimeType ct in crimes)
                    {
                        sw.WriteLine("\t\t" + ct.CrimeName + ": " + ct.CrimeCount.ToString() + " [" + ct.Percentage + "%]");
                    }
                }
                return true;
            }
            return false;
        }
开发者ID:KyleBerryCS,项目名称:Portfolio,代码行数:34,代码来源:ExportTools.cs

示例2: DumpDataToFile

        public static Boolean DumpDataToFile(object data)
        {
            if (data != null)
            {
                // Configure save file dialog box
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = "calibrate_rawdatadump"; // Default file name
                dlg.DefaultExt = ".csv"; // Default file extension
                dlg.Filter = "CSV documents (.csv)|*.csv|XML documents (.xml)|*.xml"; // Filter files by extension

                // Show save file dialog box
                Nullable<bool> result = dlg.ShowDialog();

                // Process save file dialog box results
                if (result == true)
                {
                    if (Path.GetExtension(dlg.FileName).ToLower() == ".csv")
                    {
                        return DataDumper.ToCsv(dlg.FileName, data);
                    }
                    else
                    {
                        return DataDumper.ToXml(dlg.FileName, data);
                    }
                }
            }
            return false;
        }
开发者ID:korken89,项目名称:KFlyConfig2,代码行数:28,代码来源:DataDumper.cs

示例3: saveSlides

        public static void saveSlides(Microsoft.Office.Interop.PowerPoint.Presentation presentation)
        {
            string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            //string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string filePath = desktopPath + "\\Slides.pptx";

            // Microsoft.Office.Interop.PowerPoint.FileConverter fc = new Microsoft.Office.Interop.PowerPoint.FileConverter();
            // if (fc.CanSave) { }
            //https://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx

            //Browse Files
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.InitialDirectory = desktopPath+"\\Scano";
            dlg.DefaultExt = ".pptx";
            dlg.Filter = "PPTX Files (*.pptx)|*.pptx";
            Nullable<bool> result = dlg.ShowDialog();
            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                filePath = dlg.FileName;
                //textBox1.Text = filename;
            }
            else
            {
                System.Console.WriteLine("Couldn't show the dialog.");
            }

            presentation.SaveAs(filePath,
            Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation,
            Microsoft.Office.Core.MsoTriState.msoTriStateMixed);
            System.Console.WriteLine("PowerPoint application saved in {0}.", filePath);
        }
开发者ID:dariukas,项目名称:Scanorama,代码行数:33,代码来源:FilesController.cs

示例4: btnDestination_Click

        private void btnDestination_Click(object sender, RoutedEventArgs e)
        {
            var saveFileDialog = new Microsoft.Win32.SaveFileDialog();
            saveFileDialog.FileName = "Select File to Convert";

            Nullable<bool> result = saveFileDialog.ShowDialog();

            if (result == true)
            {
                entDestination.Text = saveFileDialog.FileName.ToLower();
                if (!(entDestination.Text.EndsWith(".shp") ||
                       entDestination.Text.EndsWith(".kml")))
                {
                    entDestination.Text = "Extension Must be SHP or KML";
                    btnConvert.IsEnabled = false;
                }
                else
                {
                    if (entSource.Text.EndsWith(".shp") ||
                           entSource.Text.EndsWith(".kml"))
                    {
                        btnConvert.IsEnabled = true;
                    }
                }
            }
        }
开发者ID:adakkak,项目名称:Chomo,代码行数:26,代码来源:Window1.xaml.cs

示例5: GetFileSavePath

        public string GetFileSavePath(string title, string defaultExt, string filter)
        {
            if (VistaSaveFileDialog.IsVistaFileDialogSupported)
            {
                VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog();
                saveFileDialog.Title = title;
                saveFileDialog.DefaultExt = defaultExt;
                saveFileDialog.CheckFileExists = false;
                saveFileDialog.RestoreDirectory = true;

                saveFileDialog.Filter = filter;

                if (saveFileDialog.ShowDialog() == true)
                    return saveFileDialog.FileName;
            }
            else
            {
                Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog();
                ofd.Title = title;
                ofd.DefaultExt = defaultExt;
                ofd.CheckFileExists = false;
                ofd.RestoreDirectory = true;

                ofd.Filter = filter;

                if (ofd.ShowDialog() == true)
                    return ofd.FileName;
            }

            return "";
        }
开发者ID:rposbo,项目名称:DownmarkerWPF,代码行数:31,代码来源:DialogService.cs

示例6: btnAddNew_Click

        private void btnAddNew_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            var dlg = new Microsoft.Win32.SaveFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".mdb";
            dlg.Filter = "TestFrame Databases (.mdb)|*.mdb";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                string shortname = Globals.InputBox("Enter shortname for database:");
                Parallel.Invoke( () => {
                        TFDBManager.NewDatabase(shortname, filename);
                    });

                FillList();
                listDatabases.SelectedValue = shortname;

            }
        }
开发者ID:Cocotus,项目名称:testframe-suite,代码行数:27,代码来源:DatabaseManager.xaml.cs

示例7: OnCommand

        private void OnCommand()
        {
            // Configure open file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = _viewModel.Workspace.Path; // Default file name
            dlg.DefaultExt = ".jws"; // Default file extension
            dlg.Filter = "Jade Workspace files (.jws)|*.jws"; // Filter files by extension
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();
            
            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;

                try
                {
                    JadeData.Workspace.IWorkspace workspace = JadeData.Persistence.Workspace.Reader.Read(filename);
                    _viewModel.Workspace = new JadeControls.Workspace.ViewModel.Workspace(workspace);
                }
                catch (System.Exception e)
                {

                }
            }
        }
开发者ID:JadeHub,项目名称:Jade,代码行数:30,代码来源:SaveAsWorkspace.cs

示例8: btnExcelBS_Click

        private void btnExcelBS_Click( object sender, RoutedEventArgs e )
        {
            if ( Data.FocusedQuery == null ) return;

            Microsoft.Win32.SaveFileDialog fd = new Microsoft.Win32.SaveFileDialog( );
            fd.InitialDirectory = Environment.GetFolderPath( System.Environment.SpecialFolder.Desktop );
            fd.FileName = DefaultExcelFileName( );
            fd.ShowDialog( );
            var ci = this.Data.FocusedQuery.GoogleQuery.CompanyInfo;

            var blah = fd.ShowDialog( );
            if ( fd.ShowDialog( ).Value )
            {
                KNMFinExcel.Google.ExcelGoogle.SaveBalanceSheets( fd.FileName, ci );
            }
        }
开发者ID:kamalm87,项目名称:KNMFin,代码行数:16,代码来源:MainWindow.xaml.cs

示例9: buttonExport_Click

 private  async void buttonExport_Click(object sender, RoutedEventArgs e)
 {
     var model = getModel();
     if ((model != null) && (model.Count > 1))
     {
         try
         {
             Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
             dlg.DefaultExt = ".tsv";
             dlg.Filter = "Tab Separated values (*.tsv)|*.tsv";
             Nullable<bool> result = dlg.ShowDialog();
             String filename = null;
             if ((result != null) && result.HasValue && (result.Value == true))
             {
                 filename = dlg.FileName;
             }
             if (!String.IsNullOrEmpty(filename)){
                 this.buttonExport.IsEnabled = false;
                  await performExport(model, filename);
             }
         }
         catch (Exception/* ex */)
         {
         }
         this.buttonExport.IsEnabled = true;
     }//model
 }
开发者ID:boubad,项目名称:StatDataStoreSolution,代码行数:27,代码来源:DisplayItemsUserControl.xaml.cs

示例10: Save

		public override bool Save()
		{
			/*
			 * If the file is still undefined, open a save file dialog
			 */
			if (IsUnboundNonExistingFile)
			{
				var sf = new Microsoft.Win32.SaveFileDialog();
				sf.Filter = "All files (*.*)|*.*";
				sf.FileName = AbsoluteFilePath;

				if (!sf.ShowDialog().Value)
					return false;
				else
				{
					AbsoluteFilePath = sf.FileName;
					Modified = true;
				}
			}
			try
			{
				if (Modified)
				{
					Editor.Save(AbsoluteFilePath);
					lastWriteTime = File.GetLastWriteTimeUtc(AbsoluteFilePath);
				}
			}
			catch (Exception ex) { ErrorLogger.Log(ex); return false; }
			Modified = false;
			return true;
		}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:31,代码来源:EditorDocument.cs

示例11: GetSaveFilePath

        public string GetSaveFilePath(string exporttype)
        {
            Dictionary<string, string> type = new Dictionary<string, string>()
            {
                {"HTML", "HTML|*.html"},
                {"TXT", "TXT|*.txt"}
            };

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();

            dlg.FileName = "accounts"; // Default file name
            dlg.DefaultExt = type[exporttype].Split('*')[1]; // Default file extension
            dlg.Filter = type[exporttype]; // Filter files by extension

            // Show save file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                return dlg.FileName;

            }
            else
            {
                return null;
            }
        }
开发者ID:angela-1,项目名称:aec,代码行数:29,代码来源:BExporter.cs

示例12: btnExport_Click

 private void btnExport_Click(object sender, RoutedEventArgs e)
 {
     var dlg = new Microsoft.Win32.SaveFileDialog();
     dlg.DefaultExt = "xlsx";
     dlg.Filter = "Excel Workbook (*.xlsx)|*.xlsx|" + "HTML File (*.htm;*.html)|*.htm;*.html|" + "Comma Separated Values (*.csv)|*.csv|" + "Text File (*.txt)|*.txt";
     if (dlg.ShowDialog() == true)
     {
         var ext = System.IO.Path.GetExtension(dlg.SafeFileName).ToLower();
         ext = ext == ".htm" ? "ehtm" : ext == ".html" ? "ehtm" : ext;
         switch (ext)
         {
             case "ehtm":
                 {
                     C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Html, SaveOptions.Formatted);
                     break;
                 }
             case ".csv":
                 {
                     C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Csv, SaveOptions.Formatted);
                     break;
                 }
             case ".txt":
                 {
                     C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Text, SaveOptions.Formatted);
                     break;
                 }
             default:
                 {
                     Save(dlg.FileName,C1FlexGrid1);
                     break;
                 }
         }
     }
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:34,代码来源:MainWindow.xaml.cs

示例13: zapis_zawartosci

        bool zapis_zawartosci(byte[] zawartosc)
        {
            var dlg = new Microsoft.Win32.SaveFileDialog();
            // Set filter for file extension and default file extension 

            // Display OpenFileDialog by calling ShowDialog method 
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox 
            if (result == true)
            {
                // Open document 
                filename = dlg.FileName;
                var file = File.Open(filename, FileMode.OpenOrCreate);
                var plik = new BinaryWriter(file);
                plik.Write(zawartosc);
                plik.Close();
                return true;
            }
            else
            {
                MessageBox.Show("Problem z zapisaniem pliku");
                return false;
            }
        }
开发者ID:witkowski01,项目名称:LZSS,代码行数:25,代码来源:Zapisz.cs

示例14: NewRAWRItem_Click

        private void NewRAWRItem_Click(object sender, RoutedEventArgs e)
        {
            // Open a file chooser to choose where to put the RAWR system
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "RAWR";
            dlg.DefaultExt = ".img";
            dlg.Filter = "Virtual Image Files (.img)|*.img";
            dlg.Title = "Create New RAWR Virtual Disc";

            // Show file chooser
            Nullable<bool> result = dlg.ShowDialog();

            // Format the RAWR system on selected filename if selected
            if (result == true)
            {
                // Show my progress window of formatting my RAWR filesystem
                pgFormatRAWR.Show();

                // Create a BackgroundWorker that will create my RAWR file system
                BackgroundWorker rawrWriter = new BackgroundWorker();

                rawrWriter.DoWork += new DoWorkEventHandler(rawrWriter_DoWork);
                rawrWriter.ProgressChanged += new ProgressChangedEventHandler(rawrWriter_ProgressChanged);
                rawrWriter.RunWorkerCompleted += new RunWorkerCompletedEventHandler(rawrWriter_RunWorkerCompleted);

                rawrWriter.WorkerReportsProgress = true;
                rawrWriter.RunWorkerAsync(dlg.FileName); // Passing in my file name to the worker
            }
        }
开发者ID:DinoZAR,项目名称:Dinosaur-OS,代码行数:29,代码来源:MainWindow.xaml.cs

示例15: Execute

 public void Execute(CommandContext ctx)
 {
     Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
     string defaultFileName = string.Format("RegexTester_{0}", DateTime.Now.ToString("yyyy_MM_dd__HH_mm_ss"));
     dlg.FileName = defaultFileName;
     dlg.DefaultExt = ".txt";
     dlg.Filter = "Text documents (.txt)|*.txt";
     Nullable<bool> result = dlg.ShowDialog();
     if (result == true)
     {
         string fileName = dlg.FileName;
         StringBuilder sb = new StringBuilder();
         sb.Append("Regex Tester: version=").AppendLine(GetVersion())
           .AppendLine(new String('-', 40))
           .Append("REGEX MODE: ").AppendLine(ctx.RegexMode.ToString())
           .Append("REGEX OPTIONS: ").AppendLine(ctx.RegexOptions.ToString())
           .Append("INPUT REGEX: ").AppendLine(ctx.InputRegex)
           .Append("INPUT FORMAT: ").AppendLine(ctx.InputFormat)
           .AppendLine(string.Format("{0}INPUT TEXT{1}", PREFIX, POSTFIX))
           .AppendLine(ctx.InputText)
           .AppendLine(string.Format("{0}OUTPUT TEXT{1}", PREFIX, POSTFIX))
           .Append(ctx.OutputText);
         File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
     }
 }
开发者ID:huoxudong125,项目名称:regex-tester,代码行数:25,代码来源:SaveCommand.cs


注:本文中的Microsoft.Win32.SaveFileDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。