コード例 #1
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();
            }
        }
コード例 #2
0
        private void btnLoadExample_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.PickLoadFromFile(sInitialDirectory, sSuggestedFilename, ref sSelectedfile, sFilter))
            {
                try
                {
                    txtRequest.Text = System.IO.File.ReadAllText(sSelectedfile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error reading file.");
                }
            }
        }