Esempio n. 1
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            string          sFile = string.Empty;
            string          sConnectionSettings = string.Empty;
            PostFormSetting oPostFormSetting    = new PostFormSetting();

            SetSettingsFromForm(ref oPostFormSetting);

            if (UserIoHelper.PickSaveFileToFolder(Application.UserAppDataPath, "Connection Settings " + TimeHelper.NowMashup() + ".xml", ref sFile, "XML files (*.xml)|*.xml"))
            {
                //http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.newlinehandling(v=vs.110).aspx
                sConnectionSettings = SerialHelper.SerializeObjectToString <PostFormSetting>(oPostFormSetting);
                if (sConnectionSettings != string.Empty)
                {
                    try
                    {
                        System.IO.File.WriteAllText(sFile, sConnectionSettings);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error Saving File");
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnLoadSettings_Click(object sender, EventArgs e)
        {
            string          sFile = string.Empty;
            string          sConnectionSettings = string.Empty;
            PostFormSetting oPostFormSetting    = null;
            string          sFileContents       = string.Empty;

            if (UserIoHelper.PickLoadFromFile(Application.UserAppDataPath, "*.xml", ref sFile, "XML files (*.xml)|*.xml"))
            {
                try
                {
                    sFileContents    = System.IO.File.ReadAllText(sFile);
                    oPostFormSetting = SerialHelper.DeserializeObjectFromString <PostFormSetting>(sFileContents);
                    if (oPostFormSetting == null)
                    {
                        throw new Exception("Settings file cannot be deserialized.");
                    }
                    SetFormFromSettings(oPostFormSetting);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error Loading File");
                }

                SetFields();
            }
        }
Esempio n. 3
0
        private void btnSaveExample_Click(object sender, EventArgs e)
        {
            string sInitialDirectory = Application.StartupPath + "\\EwsPostExamples";

            string sSuggestedFilename = "*.xml";
            string sSelectedfile      = string.Empty;
            string sFilter            = "XML files (*.xml)|*.xml|All files (*.*)|*.*";

            if (UserIoHelper.PickSaveFileToFolder(sInitialDirectory, sSuggestedFilename, ref sSelectedfile, sFilter))
            {
                try
                {
                    System.IO.File.WriteAllText(sSelectedfile, txtRequest.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error writting file.");
                }
            }
        }