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


C# System.Windows.Forms.SaveFileDialog.OpenFile方法代码示例

本文整理汇总了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();
              }
        }
开发者ID:SciGit,项目名称:scigit-client,代码行数:22,代码来源:FileHistory.xaml.cs

示例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);
         }
     }
 }
开发者ID:Nayshlok,项目名称:Zombie,代码行数:21,代码来源:MainWindow.xaml.cs

示例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();
            }
        }
开发者ID:mikecrawford9,项目名称:cs134rpg,代码行数:19,代码来源:Game1.cs

示例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();
                }
        }
开发者ID:Josh-Russell,项目名称:HDATE,代码行数:15,代码来源:MainWindow.xaml.cs

示例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();
                }
            }

        }
开发者ID:caicaicai,项目名称:webTest,代码行数:25,代码来源:OptionViewModel.cs


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