本文整理汇总了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);
}
}
}
示例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);
}
}
}
}
示例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>");
}
}
}
}
示例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;
}
}
示例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);
}
}
}
}
示例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());
}
}
}
示例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);
}
}
}
示例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>");
}
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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;
}
}
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
}