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


C# Win32.SaveFileDialog类代码示例

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


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

示例1: 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

示例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: 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

示例7: ExportCards

      private void ExportCards()
      {
         var dlg = new Microsoft.Win32.SaveFileDialog();
         dlg.FileName = "Scrum Cards.xps";
         dlg.DefaultExt = ".xps";
         dlg.Filter = "XPS Documents (.xps)|*.xps";
         dlg.OverwritePrompt = true;

         var result = dlg.ShowDialog();

         if (result == false)
            return;

         var document = GenerateDocument();
         var filename = dlg.FileName;
         if (File.Exists(filename))
            File.Delete(filename);

         using (var xpsd = new XpsDocument(filename, FileAccess.ReadWrite))
         {
            var xw = XpsDocument.CreateXpsDocumentWriter(xpsd);
            xw.Write(document);
            xpsd.Close();
         }
      }
开发者ID:sceeter89,项目名称:jira-client,代码行数:25,代码来源:ScrumCardsViewModel.cs

示例8: MenuItem_Click_2

        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName = "NewFile";
            dlg.DefaultExt = ".txt";
            dlg.Filter = "Text document (.txt)|*.txt";

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

            if (result == true)
            {
                filename = dlg.FileName;
            }
            try
            {
                FileStream fs = new FileStream(filename, FileMode.Create);
                StreamWriter outstr = new StreamWriter(fs);
                outstr.Write(textBox1.Text);
                outstr.Close();
                fs.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }
开发者ID:Deswing,项目名称:File-Manager,代码行数:26,代码来源:notepad.xaml.cs

示例9: Execute

 public bool Execute()
 {
     SaveFileDialog dialog = new SaveFileDialog();
     dialog.FileName = "export.csv";
     dialog.Filter = "*.csv|*.csv|All files|*.*";
     if (dialog.ShowDialog() == true)
     {
         try
         {
             using (TextWriter writer = File.CreateText(dialog.FileName))
             {
                 writer.WriteLine("File,Time,TimeDif");
                 for (int i = 0; i < ServiceProvider.Settings.DefaultSession.Files.Count; i++)
                 {
                     var file = ServiceProvider.Settings.DefaultSession.Files[i];
                     writer.WriteLine("{0},{1},{2}", file.FileName, file.FileDate.ToString("O"),
                         (i > 0
                             ? Math.Round(
                                 (file.FileDate - ServiceProvider.Settings.DefaultSession.Files[i - 1].FileDate)
                                     .TotalMilliseconds, 0)
                             : 0));
                 }
                 PhotoUtils.Run(dialog.FileName);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error to export " + ex.Message);
             Log.Error("Error to export ", ex);
         }
     }
     return true;
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:33,代码来源:ExportCsv.cs

示例10: 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

示例11: SetConfigurationMenu

        void SetConfigurationMenu(MainWindowViewModel viewModel)
        {
            ConfigurationContextMenu.Items.Clear();
            foreach (var item in viewModel.Configrations)
            {
                ConfigurationContextMenu.Items.Add(new MenuItem { FontSize = 12, Header = item.Item1, Command = item.Item2 });
            }
            ConfigurationContextMenu.Items.Add(new Separator());
            var saveCommand = new ReactiveCommand();
            saveCommand.Subscribe(_ =>
            {
                var dialog = new Microsoft.Win32.SaveFileDialog();
                dialog.FilterIndex = 1;
                dialog.Filter = "JSON Configuration|*.json";
                dialog.InitialDirectory = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "configuration");

                if (dialog.ShowDialog() == true)
                {
                    var fName = dialog.FileName;
                    if (!fName.EndsWith(".json")) fName = fName + ".json";
                    viewModel.SaveCurrentConfiguration(fName);
                    viewModel.LoadConfigurations();
                    SetConfigurationMenu(viewModel); // reset
                }
            });
            ConfigurationContextMenu.Items.Add(new MenuItem { FontSize = 12, Header = "Save...", Command = saveCommand });
        }
开发者ID:neuecc,项目名称:PhotonWire,代码行数:27,代码来源:MainWindow.xaml.cs

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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