Esempio n. 1
0
        public bool SaveSettingsToFile()  // TestingForm oTestingForm)
        {
            bool   bRet  = false;
            string sFile = string.Empty;
            string sConnectionSettings = string.Empty;

            //SetDataFromForm(oTestingForm);

            if (UserIoHelper.PickSaveFileToFolder(FormDataFilePath, "Connection Settings " + TimeHelper.NowMashup() + ".xml", ref sFile, "XML files (*.xml)|*.xml"))
            {
                sConnectionSettings = SerialHelper.SerializeObjectToString <TestSettingsData>(SettingsData);
                if (sConnectionSettings != string.Empty)
                {
                    try
                    {
                        System.IO.File.WriteAllText(sFile, sConnectionSettings);
                        bRet = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error Saving File");
                    }
                }
            }
            return(bRet);
        }
Esempio n. 2
0
        /// <summary>
        /// save the current form settings to an xml file
        /// useriohelper is for displaying the save dialog
        /// setconnectionsettingsfromform handles which settings need to be saved
        /// then serialhelper streams that information to the file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuFileSaveSettings_Click(object sender, EventArgs e)
        {
            string sFile   = string.Empty;
            string sFilter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";

            string             sConnectionSettings = string.Empty;
            ConnectionSettings oConnectionSetting  = new ConnectionSettings();

            SetConnectionSettingsFromForm(ref oConnectionSetting);

            if (UserIoHelper.PickSaveFileToFolder(AppDomain.CurrentDomain.BaseDirectory, "Email Settings.xml", ref sFile, sFilter))
            {
                sConnectionSettings = SerialHelper.SerializeObjectToString <ConnectionSettings>(oConnectionSetting);
                if (sConnectionSettings != string.Empty)
                {
                    try
                    {
                        File.WriteAllText(sFile, sConnectionSettings);
                    }
                    catch (Exception ex)
                    {
                        txtBoxErrorLog.Clear();
                        txtBoxErrorLog.Text = ex.Message + "Error Saving File";
                    }
                }
            }
        }