本文整理汇总了C#中System.Windows.Forms.SaveFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# SaveFileDialog类的具体用法?C# SaveFileDialog怎么用?C# SaveFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaveFileDialog类属于System.Windows.Forms命名空间,在下文中一共展示了SaveFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnProcessFileDialog
private void OnProcessFileDialog(Object sender, FileDialogEventArgs e)
{
switch (e.Mode)
{
case FileDialogMode.Save:
using (var saveDialog = new SaveFileDialog())
{
saveDialog.Title = e.Title;
saveDialog.Filter = e.Filter;
saveDialog.FileName = e.DefaultFileName;
if (saveDialog.ShowDialog() != DialogResult.Cancel)
{
FormProgress.ShowProgress();
FormProgress.SetTitle("Downloading…", true);
FormProgress.SetDetails(Path.GetFileName(saveDialog.FileName));
TabControl.Enabled = false;
Application.DoEvents();
e.Continue(saveDialog.FileName);
}
else
e.Cancel();
}
break;
}
e.Handled = true;
}
开发者ID:w01f,项目名称:VolgaTeam.Dashboard,代码行数:26,代码来源:WebViewer.cs
示例2: btn_save_Click
private void btn_save_Click(object sender, System.EventArgs e)
{
var saveFileDialog = new SaveFileDialog
{
Filter = @"Bitmap files (*.bmp)|*.bmp|Image files (*.jpg)|*.jpg|PNG files (*.png)|*.png|" +
@"ICO files (*.ico)|*.ico|GIF files (*.gif)|*.gif|TIFF files (*.tiff)|*.tiff|" +
@"XPS files (*.xps)|*.xps|PDF files (*.pdf)|*.pdf|PSD files (*.psd)|*.psd"
};
if (saveFileDialog.ShowDialog() == DialogResult.Cancel) return;
// Switch
//FactorySwitch.ChooseFormat(saveFileDialog.FilterIndex).Save(saveFileDialog.FileName, pctbx_canvas.Image);
// LinkedList
//var factory = new FactoryLinked();
//factory.GetFormat(saveFileDialog.FilterIndex).Save(saveFileDialog.FileName, pctbx_canvas.Image);
// Loop
var factory = new FactoryLoop();
var formats = factory.GetValidFormats(saveFileDialog.FilterIndex);
foreach (var item in formats)
{
item.Save(saveFileDialog.FileName, pctbx_canvas.Image);
}
}
开发者ID:RomanGolovko,项目名称:Valtech_,代码行数:25,代码来源:Form1.cs
示例3: button4_Click
private void button4_Click(object sender, EventArgs e)
{
SaveFileDialog sd = new SaveFileDialog();
sd.Filter = "FlexFile (*.flx)|*.flx";
sd.FilterIndex = 0;
sd.DefaultExt = ".flx";
sd.AddExtension = true;
if (sd.ShowDialog() == DialogResult.OK)
{
BinaryWriter wr = new BinaryWriter(new FileStream(sd.FileName, FileMode.Create));
wr.Write(header);
for (int i = 0; i < cnt * 256; i++)
{
wr.Write((int)0);
wr.Write((int)0);
}
foreach (Section s in sex)
{
int ofs = (int)wr.BaseStream.Position;
int sz = s.data.Length;
wr.BaseStream.Position = 0x80 + 8 * s.id;
wr.Write(ofs);
wr.Write(sz);
wr.BaseStream.Position = ofs;
wr.Write(s.data);
}
wr.Close();
}
}
开发者ID:winterheart,项目名称:game-utilities,代码行数:29,代码来源:Form1.cs
示例4: SaveToFile
internal void SaveToFile()
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.AddExtension = true;
//sfd.CheckFileExists = true;
//sfd.CheckPathExists = true;
sfd.CreatePrompt = true;
sfd.DefaultExt = "rtf";
sfd.Filter = "リッチテキストフォーマット|*.rtf";
if (sfd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
Stream write = null;
try
{
write = sfd.OpenFile();
rtb_thread_main.SaveFile(write, RichTextBoxStreamType.RichText);
MessageBox.Show("セーブ成功しました。");
}
catch (System.IO.IOException)
{
MessageBox.Show("セーブ失敗ました。");
}
finally
{
if (write != null)
{
write.Close();
}
}
}
}
开发者ID:MaiReo,项目名称:SimpleRobotDemo,代码行数:31,代码来源:frm_NewThread.cs
示例5: btnSave_Click
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "图象另存为";
sfd.OverwritePrompt = true;
sfd.CheckPathExists = true;
sfd.Filter = cmbSaveFiletype.Text + "|" + cmbSaveFiletype.Text;
sfd.ShowHelp = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
string strFileName = sfd.FileName;
switch (cmbSaveFiletype.Text)
{
case "*.bmp":
m_bitmap.Save(strFileName, ImageFormat.Bmp);
break;
case "*.jpg":
m_bitmap.Save(strFileName, ImageFormat.Jpeg);
break;
case "*.gif":
m_bitmap.Save(strFileName, ImageFormat.Gif);
break;
case "*.tif":
m_bitmap.Save(strFileName, ImageFormat.Tiff);
break;
}
MessageBox.Show("图象文件格式转换成功!", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
开发者ID:ShiJess,项目名称:CompanyStudy,代码行数:32,代码来源:imageConvert.cs
示例6: SaveDIBAs
public static bool SaveDIBAs(string picname, IntPtr bminfo, IntPtr pixdat)
{
SaveFileDialog sd = new SaveFileDialog();
sd.FileName = picname;
sd.Title = "Save bitmap as...";
sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*";
sd.FilterIndex = 1;
if (sd.ShowDialog() != DialogResult.OK)
return false;
Guid clsid;
if (!GetCodecClsid(sd.FileName, out clsid))
{
MessageBox.Show("Unknown picture format for extension " + Path.GetExtension(sd.FileName),
"Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
IntPtr img = IntPtr.Zero;
int st = GdipCreateBitmapFromGdiDib(bminfo, pixdat, ref img);
if ((st != 0) || (img == IntPtr.Zero))
return false;
st = GdipSaveImageToFile(img, sd.FileName, ref clsid, IntPtr.Zero);
GdipDisposeImage(img);
return st == 0;
}
开发者ID:romanu6891,项目名称:fivemen,代码行数:28,代码来源:Gdip.cs
示例7: CommandExport
public void CommandExport(object param)
{
if (!TilePoolExists(param))
return;
Guid uid = (Guid)param;
TilePool tilePool = Editor.Project.TilePoolManager.Pools[uid];
using (System.Drawing.Bitmap export = tilePool.TileSource.CreateBitmap()) {
using (SaveFileDialog ofd = new SaveFileDialog()) {
ofd.Title = "Export Raw Tileset";
ofd.Filter = "Portable Network Graphics (*.png)|*.png|Windows Bitmap (*.bmp)|*.bmp|All Files|*";
ofd.OverwritePrompt = true;
ofd.RestoreDirectory = false;
if (ofd.ShowDialog() == DialogResult.OK) {
try {
export.Save(ofd.FileName);
}
catch {
MessageBox.Show("Could not save image file.", "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
}
开发者ID:jaquadro,项目名称:Treefrog,代码行数:26,代码来源:TilePoolCommandActions.cs
示例8: btnSaveSetList_Click
private void btnSaveSetList_Click(object sender, EventArgs e)
{
using (SaveFileDialog dlgSave = new SaveFileDialog())
{
dlgSave.Title = "Select where to save the training set to...";
dlgSave.Filter = "ENFORM Set File (*.eset)|*.eset|Text File (*.txt) |*.txt|Any file (*.*)|*.*";
if (dlgSave.ShowDialog() == DialogResult.OK)
{
using (StreamWriter w = new StreamWriter(dlgSave.FileName, false))
{
foreach (selectedSet.SelectedIndexRow row in selectedTable.Rows)
{
if (row.testingset || row.trainingset)
{
w.WriteLine(row.subjectid.ToString() + "," + Convert.ToInt32(row.trainingset).ToString() + "," + Convert.ToInt32(row.testingset).ToString() + "," + feretDataSet.faces.Select("subjectid=" +row.subjectid.ToString())[0]["filename"].ToString() );
}
}
}
}
}
}
开发者ID:NoxHarmonium,项目名称:enform,代码行数:26,代码来源:frmFeretExplorer.cs
示例9: EditValue
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
if (context == null || provider == null || context.Instance == null)
{
return base.EditValue(provider, value);
}
FileDialog fileDlg;
if (context.PropertyDescriptor.Attributes[typeof(SaveFileAttribute)] == null)
{
fileDlg = new OpenFileDialog();
}
else
{
fileDlg = new SaveFileDialog();
}
fileDlg.Title = "Select " + context.PropertyDescriptor.DisplayName;
fileDlg.FileName = (string) value;
FileDialogFilterAttribute filterAtt = (FileDialogFilterAttribute) context.PropertyDescriptor.Attributes[typeof(FileDialogFilterAttribute)];
if (filterAtt != null)
{
fileDlg.Filter = filterAtt.Filter;
}
if (fileDlg.ShowDialog() == DialogResult.OK)
{
value = fileDlg.FileName;
}
fileDlg.Dispose();
return value;
}
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:31,代码来源:UIFilenameEditor.cs
示例10: buttonExtract_Click
private void buttonExtract_Click(object sender, EventArgs e)
{
if (!File.Exists(txtCompiledFile.Text))
{
MessageBox.Show(this, "Please select a compiled ArchAngel template file.", "Missing File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = ".stz";
dialog.Filter = "ArchAngel templates (*.stz)|*.stz";
if (dialog.ShowDialog() == DialogResult.OK)
{
if (!Directory.Exists(Path.GetDirectoryName(dialog.FileName)))
{
MessageBox.Show(this, "Please specify a valid save location.", "Invalid Folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (File.Exists(dialog.FileName))
{
Slyce.Common.Utility.DeleteFileBrute(dialog.FileName);
}
Project.ExtractTemplateFromCompiledTemplate(txtCompiledFile.Text, dialog.FileName);
this.FileName = dialog.FileName;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:28,代码来源:frmExtractTemplate.cs
示例11: Form1
public Form1()
{
InitializeComponent();
cd = new ColorDialog();
ld = new SHMUP.Screens.Levels.LevelManager.LevelData();
sfd = new SaveFileDialog();
sfd.Filter = "SHMUP Level File (*.lvl)|*.lvl";
ofd = new OpenFileDialog();
ofd.Filter = "SHMUP Level File (*.lvl)|*.lvl";
//for (int i = 0; i < (int)SHMUP.Screens.Levels.LevelManager.bosses.ZZZEndOfList; i++)
//{
// comBossType.Items.Add((SHMUP.Screens.Levels.LevelManager.bosses)i);
//}
string appPath = Application.ExecutablePath.Remove(Application.ExecutablePath.LastIndexOf(Path.DirectorySeparatorChar));
String[] bosses = Directory.GetFiles(Path.Combine(Path.Combine(appPath, "Content"), "Bosses"), "*.bos");
for (int i = 0; i < bosses.Length; i++)
{
bosses[i] = bosses[i].Remove(0, Path.Combine(Path.Combine(appPath, "Content"), "Bosses").Length + 1);
bosses[i] = bosses[i].Remove(bosses[i].LastIndexOf(".bos"));
comBossType.Items.Add(bosses[i]);
}
for (int i = 0; i < (int)SHMUP.Screens.Levels.LevelManager.enemies.ZZZEndOfList; i++)
{
comEnemyType.Items.Add((SHMUP.Screens.Levels.LevelManager.enemies)i);
}
ClearAll();
}
开发者ID:CharcoalStyles,项目名称:SHMUP,代码行数:33,代码来源:Form1.cs
示例12: dialSaveFile
public static int dialSaveFile(ref string dir,
string filter,
string title,
int filterIndex,
out string path)
{
path = "";
SaveFileDialog dlg = new SaveFileDialog();
if (Directory.Exists(dir))
dlg.InitialDirectory = dir;
dlg.Title = title;
dlg.Filter = filter;
dlg.RestoreDirectory = true;
dlg.FilterIndex = filterIndex;
if (dlg.ShowDialog() == DialogResult.OK)
{
path = dlg.FileName;
dir = Path.GetDirectoryName(path);
return dlg.FilterIndex;
}
return -1;
}
开发者ID:emm274,项目名称:fcObj,代码行数:27,代码来源:xfiles.cs
示例13: yesButton_Click
private void yesButton_Click(object sender, EventArgs e)
{
using (SaveFileDialog save = new SaveFileDialog())
{
save.DefaultExt = "sql";
save.OverwritePrompt = true;
save.Filter = "SQL Script Files (*.sql)|*.sql|All Files (*.*)|*.*";
save.FileName = String.Format("{0}.sql", _tableName);
save.Title = "Save SQLite Change Script";
DialogResult = save.ShowDialog(this);
if (DialogResult == DialogResult.OK)
{
_defaultSave = _saveOrig.Checked;
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(save.FileName, false, Encoding.UTF8))
{
if ((_show.Visible == true && _saveOrig.Checked == true) || (_show.Visible == false && _splitter.Panel2Collapsed == true))
{
if (_show.Visible == true) writer.WriteLine("/*");
writer.WriteLine(_original.Text.Replace("\r", "").TrimEnd('\n').Replace("\n", "\r\n"));
if (_show.Visible == true) writer.WriteLine("*/");
}
if (_show.Visible == true || _splitter.Panel2Collapsed == false)
writer.WriteLine(_script.Text.Replace("\r", "").TrimEnd('\n').Replace("\n", "\r\n"));
}
}
}
Close();
}
开发者ID:cody82,项目名称:spacewar-arena,代码行数:31,代码来源:ChangeScriptDialog.cs
示例14: barra1_click_imprimir_button
private void barra1_click_imprimir_button()
{
SaveFileDialog sfDialog = new SaveFileDialog();
sfDialog.AddExtension = true;
sfDialog.Filter = "PDF Files (*.pdf)|*.PDF";
sfDialog.DefaultExt = ".pdf";
DialogResult drResult = sfDialog.ShowDialog();
if (drResult.Equals(DialogResult.OK))
{
switch (tabControl1.SelectedIndex)
{
case 0:
convertidor.ExportGrid(dgv_Tab0_Historial, sfDialog.FileName,"BODEGA");
break;
case 1:
convertidor.ExportGrid(dgv_Tab1_Historial, sfDialog.FileName,"UBICACION");
break;
case 2:
convertidor.ExportGrid(dgv_Tab2_Historial, sfDialog.FileName,"TIPO PRODUCTO");
break;
case 3:
convertidor.ExportGrid(dataGridView1, sfDialog.FileName, "Verificacion Inventario");
break;
}
}
}
开发者ID:daguilae,项目名称:MRP,代码行数:27,代码来源:frmMantenimientoInventario.cs
示例15: export
public bool export()
{
checkStuff();
SaveFileDialog ofd = new SaveFileDialog();
ofd.Filter = LanguageManager.Get("Filters", "png");
if (ofd.ShowDialog(win) == DialogResult.Cancel) return false;
calcSizes();
Bitmap b = new Bitmap(tx, ty);
Graphics bgfx = Graphics.FromImage(b);
int x = 0;
foreach (PixelPalettedImage img in imgs)
{
int y = 0;
foreach (Palette pal in pals)
{
Bitmap bb = img.render(pal);
bgfx.DrawImage(bb, x, y, bb.Width, bb.Height);
bb.Dispose();
y += tys;
}
x += img.getWidth();
}
b.Save(ofd.FileName);
b.Dispose();
return true;
}
开发者ID:MCGlux,项目名称:NSMB-Editor,代码行数:29,代码来源:GraphicsSet.cs
示例16: SaveRadTree
public static void SaveRadTree(RadTreeView view, IWin32Window frm = null, string filename = "")
{
var saveFileDialogCsv = new SaveFileDialog();
saveFileDialogCsv.Title = "Save data to Comma Separated File";
saveFileDialogCsv.Filter = "CSV or Excel|*.csv";
saveFileDialogCsv.CheckPathExists = true;
saveFileDialogCsv.DefaultExt = "csv";
saveFileDialogCsv.AddExtension = true;
saveFileDialogCsv.OverwritePrompt = true;
saveFileDialogCsv.InitialDirectory = Repository.DataFolder;
saveFileDialogCsv.FileName = filename;
if (saveFileDialogCsv.ShowDialog(frm) == System.Windows.Forms.DialogResult.OK)
{
try
{
sb = new StringBuilder();
foreach (var node in view.Nodes)
{
sb.AppendLine(node.Text.Replace("<=", ","));
ListNodes(node);
}
System.IO.File.WriteAllText(saveFileDialogCsv.FileName, sb.ToString(),Encoding.UTF8);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Unexpected Error");
}
}
}
开发者ID:kenlassesen,项目名称:dnafamilytree,代码行数:29,代码来源:SaveUtility.cs
示例17: btnExport_Click
private void btnExport_Click(object sender, EventArgs e)
{
var saveFileDlg = new SaveFileDialog {Filter = Resources.SaveFileFilter};
if (DialogResult.OK.Equals(saveFileDlg.ShowDialog()))
{
var workbookParameterContainer = new WorkbookParameterContainer();
workbookParameterContainer.Load(@"Template\Template.xml");
SheetParameterContainer sheetParameterContainer = workbookParameterContainer["重复单元格式化器"];
ExportHelper.ExportToLocal(@"Template\Template.xls", saveFileDlg.FileName,
new SheetFormatter("重复单元格式化器",
new RepeaterFormatter<StudentInfo>(sheetParameterContainer["rptStudentInfo_Start"],
sheetParameterContainer["rptStudentInfo_End"], StudentLogic.GetList(),
new CellFormatter<StudentInfo>(sheetParameterContainer["Name"], t => t.Name),
new CellFormatter<StudentInfo>(sheetParameterContainer["Gender"], t => t.Gender ? "男" : "女"),
new CellFormatter<StudentInfo>(sheetParameterContainer["Class"], t => t.Class),
new CellFormatter<StudentInfo>(sheetParameterContainer["RecordNo"], t => t.RecordNo),
new CellFormatter<StudentInfo>(sheetParameterContainer["Phone"], t => t.Phone),
new CellFormatter<StudentInfo>(sheetParameterContainer["Email"], t => t.Email)
)
)
);
}
}
开发者ID:geekmi,项目名称:ExcelReport,代码行数:25,代码来源:MainForm.cs
示例18: FileSave
/// <summary>
/// Displays a save file dialog.
/// </summary>
/// <param name="title">Dialog title.</param>
/// <param name="startPath">Initial path.</param>
/// <param name="extension">File extension filter.</param>
/// <param name="callback">Callback that is executed after the dialog completes.</param>
/// <returns>True if succeeded.</returns>
public static bool FileSave(String title, String startPath, String extension, Action<String> callback)
{
var dialog = new SaveFileDialog
{
Title = title,
InitialDirectory = startPath,
DefaultExt = @"*.*",
Filter = extension,
CheckPathExists = true,
OverwritePrompt = true
};
if (dialog.ShowDialog() == DialogResult.OK)
{
if (callback != null)
{
callback(dialog.FileName);
}
}
else
{
if (callback != null)
{
callback(String.Empty);
}
return false;
}
return true;
}
开发者ID:tritao,项目名称:flood,代码行数:37,代码来源:Neutral.cs
示例19: init
private void init()
{
saveFileDialog = new SaveFileDialog();
applyFilterOptions();
string initialDirectory = null;
try
{
initialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath);
}
catch
{
LOG.WarnFormat("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", conf.OutputFileAsFullpath);
}
if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
{
saveFileDialog.InitialDirectory = initialDirectory;
}
else if (Directory.Exists(conf.OutputFilePath))
{
saveFileDialog.InitialDirectory = conf.OutputFilePath;
}
// The following property fixes a problem that the directory where we save is locked (bug #2899790)
saveFileDialog.RestoreDirectory = true;
saveFileDialog.OverwritePrompt = true;
saveFileDialog.CheckPathExists = false;
saveFileDialog.AddExtension = true;
ApplySuggestedValues();
}
开发者ID:BallisticLingonberries,项目名称:ShareX,代码行数:29,代码来源:SaveImageFileDialog.cs
示例20: ExportGridEx
public static void ExportGridEx(Janus.Windows.GridEX.GridEX gridEx )
{
Stream sw = null;
try
{
var sd = new SaveFileDialog { Filter = "Excel File (*.xml)|*.xml" };
if (sd.ShowDialog() == DialogResult.OK)
{
//sw = new FileStream(sd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
sw = new FileStream(sd.FileName, FileMode.Create);
GridEXExporter grdListExporter = new GridEXExporter();
grdListExporter.IncludeExcelProcessingInstruction = true;
grdListExporter.IncludeFormatStyle = true;
grdListExporter.IncludeHeaders = true;
grdListExporter.GridEX = gridEx;
grdListExporter.Export(sw);
Utility.ShowMsg("Xuất dữ liệu thành công");
}
}
catch (Exception ex)
{
Utility.ShowMsg(ex.Message);
}
finally
{
if (sw != null)
{
sw.Flush();
sw.Close();
sw.Dispose();
}
}
}
开发者ID:khaha2210,项目名称:CodeNewTeam,代码行数:33,代码来源:ExcelReport.cs
注:本文中的System.Windows.Forms.SaveFileDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论