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


C# SaveFileDialog.OpenFile方法代码示例

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


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

示例1: ExportDataGrid

    public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows, string fileName)
    {
        if (Application.Current.HasElevatedPermissions)
        {

            var filePath ="C:" + Path.DirectorySeparatorChar +"Nithesh"+Path.DirectorySeparatorChar +fileName + ".XML";

            File.Create(filePath);
            Stream outputStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite);

            ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, "XML", outputStream);
        }
        else
        {
            SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2, DefaultFileName = fileName };

            if (objSFD.ShowDialog() == true)
            {
                string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
                Stream outputStream = objSFD.OpenFile();

                ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
            }
        }
    }
开发者ID:shenoyroopesh,项目名称:Gama,代码行数:25,代码来源:DataGridExtensions.cs

示例2: Export

        public void Export(object parameter)
        {
            RadGridView grid = parameter as RadGridView;
            if (grid != null)
            {
                grid.ElementExporting -= this.ElementExporting;
                grid.ElementExporting += this.ElementExporting;

                grid.ElementExported -= this.ElementExported;
                grid.ElementExported += this.ElementExported;

                string extension = "xls";
                ExportFormat format = ExportFormat.Html;

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.DefaultExt = extension;
                dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel");
                dialog.FilterIndex = 1;

                if (dialog.ShowDialog() == true)
                {
                    using (Stream stream = dialog.OpenFile())
                    {
                        GridViewExportOptions options = new GridViewExportOptions();
                        options.Format = format;
                        options.ShowColumnHeaders = true;
                        options.Encoding = System.Text.Encoding.UTF8;
                        grid.Export(stream, options);
                    }
                }
            }
        }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:32,代码来源:ExportingModel.cs

示例3: exportHandler

    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|(*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of LaTeX
                //   commands to draw the shapes
                using(StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write("<?xml version='1.0' standalone='no'?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg xmlns='http://www.w3.org/2000/svg' version='1.1'> ");

                    Visual visual = new VisualSVG(writer);

                    //Draw all shapes
                    foreach (Shape shape in shapes)
                    {
                        shape.visual = visual;

                        shape.Draw();
                    }

                    writer.Write("</svg>");
                }
            }
        }
    }
开发者ID:Tyskai,项目名称:ShapesOpdracht3,代码行数:34,代码来源:ShapeDrawing.cs

示例4: CreateNewEndpoint_OnClick

		private async void CreateNewEndpoint_OnClick(object sender, RoutedEventArgs e) {
			this.CreateNewEndpoint.IsEnabled = false;
			this.CreateNewEndpoint.Cursor = Cursors.AppStarting;
			try {
				var cts = new CancellationTokenSource();
				var endpointTask = this.OwnEndpointServices.CreateAsync(cts.Token);
				var dialog = new SaveFileDialog();
				bool? result = dialog.ShowDialog(this);
				if (result.HasValue && result.Value) {
					Uri addressBookEntry = await this.OwnEndpointServices.PublishAddressBookEntryAsync(await endpointTask, cts.Token);
					await this.SetEndpointAsync(await endpointTask, addressBookEntry, cts.Token);
					using (var stream = dialog.OpenFile()) {
						var writer = new BinaryWriter(stream, Encoding.UTF8);
						writer.SerializeDataContract(addressBookEntry);
						writer.Flush();
						await this.Channel.Endpoint.SaveAsync(stream, cts.Token);
					}
				} else {
					cts.Cancel();
				}
			} finally {
				this.CreateNewEndpoint.Cursor = Cursors.Arrow;
				this.CreateNewEndpoint.IsEnabled = true;
			}
		}
开发者ID:raam030,项目名称:IronPigeon,代码行数:25,代码来源:MainWindow.xaml.cs

示例5: exportHandler

    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of SVG
                //   commands to draw the shapes

                String SVGtext = "<?xml version=\"1.0\" standalone=\"no\"?>" +
                    "\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"" +
                    "\r\n\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" +
                    "\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";
                foreach (Shape shape in shapes)
                {
                    SVGtext = SVGtext + shape.Conversion("SVG");
                }
                SVGtext = SVGtext + "\r\n</svg>";
                    using (StreamWriter writer = new StreamWriter(stream))
                {
                        // Write strings to the file here using:
                        writer.WriteLine(SVGtext);
                }
            }
        }
    }
开发者ID:YannickMeijer,项目名称:Lab4,代码行数:33,代码来源:ShapeDrawing.cs

示例6: button1_Click

 private void button1_Click(object sender, RoutedEventArgs e)
 {
     SaveFileDialog dialog = new SaveFileDialog();
     dialog.FileName = "result.csv";
     dialog.Filter = "CSVファイル(*.csv)|*.csv|全てのファイル(*.*)|*.*";
     dialog.OverwritePrompt = true;
     dialog.CheckPathExists = true;
     bool? res = dialog.ShowDialog();
     if (res.HasValue && res.Value)
     {
         try
         {
             if (mainWin.fileWriter != null) mainWin.fileWriter.Flush();
             System.IO.Stream fstream = dialog.OpenFile();
             System.IO.Stream fstreamAppend = new System.IO.FileStream(dialog.FileName+"-log.csv", System.IO.FileMode.OpenOrCreate);
             if (fstream != null && fstreamAppend != null)
             {
                 textBox1.Text = dialog.FileName;
                 mainWin.fileWriter = new System.IO.StreamWriter(fstream);
                 mainWin.logWriter = new System.IO.StreamWriter(fstreamAppend);
             }
         }
         catch (Exception exp)
         {
             MessageBox.Show(exp.ToString());
         }
     }
 }
开发者ID:einbrain,项目名称:WPFDemoServer,代码行数:28,代码来源:Window1.xaml.cs

示例7: ExportPdf

        private void ExportPdf(object sender, RoutedEventArgs e)
        {
            //export the combined PDF
            SaveFileDialog dialog = new SaveFileDialog()
            {
                DefaultExt = "pdf",
                Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", "pdf", "Pdf"),
                FilterIndex = 1
            };

            if (dialog.ShowDialog() == true)
            {
                //export the data from the two RadGridVies instances in separate documents
                RadFixedDocument playersDoc = this.playersGrid.ExportToRadFixedDocument();
                RadFixedDocument clubsDoc = this.clubsGrid.ExportToRadFixedDocument();

                //merge the second document into the first one
                playersDoc.Merge(clubsDoc);

                using (Stream stream = dialog.OpenFile())
                {
                    new PdfFormatProvider().Export(playersDoc, stream);
                }
            }
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:25,代码来源:MainPage.xaml.cs

示例8: exportHandler

    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|(*.svg)";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                //import header from a file.
                string[] header = { @"<?xml version =""1.0"" standalone=""no""?>", @"<!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" ""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"">", @"<svg xmlns=""http://www.w3.org/2000/svg"" version=""1.1"">" };
                //import the SVG shapes.

                using (StreamWriter writer = new StreamWriter(stream))
                {
                    foreach (string headerLine in header)
                    {
                        writer.WriteLine(headerLine);
                    }

                    foreach(Shape shape in shapes)
                    {
                        shape.drawTarget = new DrawSVG();
                        shape.Draw();
                        writer.WriteLine(shape.useShape);
                    }
                    writer.WriteLine("</svg>");
                }
            }
        }
    }
开发者ID:RobinSikkens,项目名称:MSO-Lab-4,代码行数:35,代码来源:ShapeDrawing.cs

示例9: ExportXlsx

        private void ExportXlsx(object sender, RoutedEventArgs e)
        {
            //export the combined PDF
            SaveFileDialog dialog = new SaveFileDialog()
            {
                DefaultExt = "xlsx",
                Filter = String.Format("Workbooks (*.{0})|*.{0}|All files (*.*)|*.*", "xlsx"),
                FilterIndex = 1
            };

            if (dialog.ShowDialog() == true)
            {

                //export the data from the two RadGridVies instances in separate documents
                Workbook playersDoc = this.playersGrid.ExportToWorkbook();
                Workbook clubsDoc = this.clubsGrid.ExportToWorkbook();

                //merge the second document into the first one
                Worksheet clonedSheet = playersDoc.Worksheets.Add();
                clonedSheet.CopyFrom(clubsDoc.Sheets[0] as Worksheet);

                using (Stream stream = dialog.OpenFile())
                {
                    new XlsxFormatProvider().Export(playersDoc, stream);
                }
            }
        }
开发者ID:CJMarsland,项目名称:xaml-sdk,代码行数:27,代码来源:MainPage.xaml.cs

示例10: Save_Click

 protected void Save_Click(Object sender, EventArgs e)
 {
     SaveFileDialog s = new SaveFileDialog();
     if(s.ShowDialog() == DialogResult.OK) {
       StreamWriter writer = new StreamWriter(s.OpenFile());
       writer.Write(text.Text);
       writer.Close();
     }
 }
开发者ID:jiteshjha,项目名称:TextEditor,代码行数:9,代码来源:texteditor.cs

示例11: exportHandler

    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "Scalable Vector Graphics (*.svg)|*.svg|TeX files (*.tex)|*.tex";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                string name = saveFileDialog.FileName;
                string ext = Path.GetExtension(saveFileDialog.FileName).ToLower();

                switch(ext){
                    case ".tex":
                        LatexGenerator lg = new LatexGenerator();
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            lg.FileWriter = writer;
                            writer.WriteLine("\\documentclass{article}");
                            writer.WriteLine("\\usepackage{tikz}");
                            writer.WriteLine("\\begin{document}");
                            writer.WriteLine("\\begin{tikzpicture}");
                            writer.WriteLine("\\begin{scope}[yscale= -3, xscale= 3]");
                            foreach(Shape s in this.shapes)
                            {
                                s.OutputApi = lg;
                                s.Draw();
                            }
                            writer.WriteLine("\\end{scope}");
                            writer.WriteLine("\\end{tikzpicture}");
                            writer.WriteLine("\\end{document}");
                        }
                        break;
                    default: //save as svg by default
                        SvgGenerator sg = new SvgGenerator();
                        using (StreamWriter writer = new StreamWriter(stream))
                        {
                            sg.FileWriter = writer;
                            writer.WriteLine("<?xml version=\"1.0\" standalone=\"no\"?>");
                            writer.WriteLine("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
                            writer.WriteLine("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
                            foreach (Shape s in this.shapes)
                            {
                                s.OutputApi = sg;
                                s.Draw();
                            }
                            writer.WriteLine("</svg>");
                        }
                        break;
                }
            }
        }
    }
开发者ID:Chronophobe,项目名称:MSO_P3b,代码行数:57,代码来源:ShapeDrawing.cs

示例12: Save

		public override bool Save(DecompilerTextView textView)
		{
			SaveFileDialog dlg = new SaveFileDialog();
			dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(key));
			if (dlg.ShowDialog() == true) {
				data.Position = 0;
				using (var fs = dlg.OpenFile()) {
					data.CopyTo(fs);
				}
			}
			return true;
		}
开发者ID:tris2481,项目名称:ILSpy,代码行数:12,代码来源:ResourceEntryNode.cs

示例13: SaveFileMenuItem_Click

        private void SaveFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.FileName = filename;
            Nullable<bool> result = dialog.ShowDialog();
            if(result == true)
            {
                TextRange range = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
                range.Save(dialog.OpenFile(), DataFormats.Text);
            }

            //range.Save();
        }
开发者ID:CBStilborg,项目名称:BasicProgrammingWithC-Sharp,代码行数:13,代码来源:MainWindow.xaml.cs

示例14: DetermineFile

        // TODO Fix
#else
        /// <summary>
        /// Determines the filename of the file what will be used.
        /// </summary>
        /// <returns>The <see cref="Stream"/> of the file or <c>null</c> if no file was selected by the user..</returns>
        /// <remarks>
        /// If this method returns a valid <see cref="Stream"/> object, the <c>FileName</c> property will be filled 
        /// with the safe filename. This can be used for display purposes only.
        /// </remarks>
        public virtual Stream DetermineFile()
        {
            var fileDialog = new SaveFileDialog();
            fileDialog.Filter = Filter;

            bool result = fileDialog.ShowDialog() ?? false;
            if (result)
            {
                FileName = fileDialog.SafeFileName;
            }

            return result ? fileDialog.OpenFile() : null;
        }
开发者ID:jensweller,项目名称:Catel,代码行数:23,代码来源:SaveFileService.cs

示例15: SaveStyleSheet_Click

 private void SaveStyleSheet_Click(object sender, RadRoutedEventArgs e)
 {
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = "Xaml Files|*.xaml";
     if (sfd.ShowDialog() == true)
     {
         using (var stream = sfd.OpenFile())
         {
             Stylesheet stylesheet = new Stylesheet();
             stylesheet.ExtractStylesheetFromDocument(this.editor.Document);
             XamlFormatProvider.SaveStylesheet(stylesheet, stream);
         }
     }
 }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:14,代码来源:Example.xaml.cs


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