Save() public method

Saves the configuration to a file on disk.
public Save ( string filePath ) : void
filePath string
return void
コード例 #1
0
ファイル: MainForm.cs プロジェクト: mcooper87/UA-.NET
        private void File_SaveMI_Click(object sender, EventArgs e)
        {
            try
            {
                // select the directory.
                string        filePath = null;
                DirectoryInfo dirInfo  = new DirectoryInfo(Environment.CurrentDirectory);

                if (m_testConfiguration.FilePath != null)
                {
                    FileInfo fileInfo = new FileInfo(m_testConfiguration.FilePath);

                    if (fileInfo.Directory.Exists)
                    {
                        dirInfo = fileInfo.Directory;
                    }

                    filePath = m_testConfiguration.FilePath;
                }
                else
                {
                    filePath = dirInfo.FullName + "\\TestConfiguration";
                }

                SaveFileDialog dialog = new SaveFileDialog();

                dialog.CheckFileExists  = false;
                dialog.CheckPathExists  = true;
                dialog.DefaultExt       = ".xml";
                dialog.Filter           = "Config Files (*.xml)|*.xml|All Files (*.*)|*.*";
                dialog.ValidateNames    = true;
                dialog.Title            = "Save Test Configuration File";
                dialog.FileName         = filePath;
                dialog.InitialDirectory = dirInfo.FullName;

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                m_testConfiguration.Save(dialog.FileName);

                // update the file list.
                Utils.UpdateRecentFileList("Server Test Client", dialog.FileName, 4);
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }