本文整理汇总了C#中System.Windows.Forms.SaveFileDialog.OpenFile方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.SaveFileDialog.OpenFile方法的具体用法?C# System.Windows.Forms.SaveFileDialog.OpenFile怎么用?C# System.Windows.Forms.SaveFileDialog.OpenFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.SaveFileDialog
的用法示例。
在下文中一共展示了System.Windows.Forms.SaveFileDialog.OpenFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClickSave
private void ClickSave(object sender, EventArgs e)
{
string hash = hashes[fileHistory.SelectedIndex];
string text = LoadFile(hash);
if (text == null) {
MessageBox.Show(this, "The file was deleted in this revision.", "Deleted");
return;
}
var dialog = new System.Windows.Forms.SaveFileDialog();
dialog.FileName = this.filename;
dialog.Filter = "All files (*.*)|*.*";
dialog.FilterIndex = 0;
dialog.InitialDirectory = ProjectMonitor.GetProjectDirectory(project);
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
var file = dialog.OpenFile();
byte[] bytes = Encoding.Default.GetBytes(text);
file.Write(bytes, 0, bytes.Length);
file.Close();
}
}
示例2: CommandBinding_Executed_1
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
{
System.Windows.Forms.SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog();
saveDialog.AddExtension = true;
saveDialog.DefaultExt = ".zac";
if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
Stream myStream = null;
if ((myStream = saveDialog.OpenFile()) != null)
{
saveControl.save(myStream, GameBoard);
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.Message);
}
}
}
示例3: SaveMap
public void SaveMap()
{
System.Windows.Forms.SaveFileDialog openFileDialog1 = new System.Windows.Forms.SaveFileDialog();
openFileDialog1.Filter = "RPG Map Files (.rpgmf)|*.rpgmf";
System.Windows.Forms.DialogResult userClickedOK = openFileDialog1.ShowDialog();
if (userClickedOK == System.Windows.Forms.DialogResult.OK)
{
// Open the selected file to read.
System.IO.Stream fileStream = openFileDialog1.OpenFile();
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(fileStream))
{
// Read the first line from the file and write it the textbox.
map.SaveMap(writer);
}
fileStream.Close();
}
}
示例4: SavePlayer
public void SavePlayer()
{
System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
Stream myStream;
dlg.Filter = "He Dies At The End (.hdate) | *.hdate";
if(dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK == true)
if ((myStream = dlg.OpenFile()) != null)
{
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(myStream, p1);
myStream.Close();
}
}
示例5: ExportProxysExec
private void ExportProxysExec()
{
Stream myStream;
System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
saveFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog.FilterIndex = 2;
saveFileDialog.RestoreDirectory = true;
saveFileDialog.FileName = "proxys.txt";
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if ((myStream = saveFileDialog.OpenFile()) != null)
{
StreamWriter writer = new StreamWriter(myStream);
foreach (ProxyServer proxy in option.Proxys)
writer.WriteLine(proxy.Server);
writer.Close();
myStream.Close();
}
}
}