Exemplo n.º 1
0
        private void btnDownloadAndStart_Click(object sender, EventArgs e)
        {
            try
            {
                _profile.LocalCertificateStore.Certificate = Registration.GetSignedCertificate(Program.SIGNUP_URI, _profile.LocalCertificateStore);

                using (FileStream fS = new FileStream(_profileFilePath, FileMode.Create, FileAccess.ReadWrite))
                {
                    _profile.WriteTo(fS);
                }

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error orrured while downloading profile certificate:\r\n\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void SaveProfile()
        {
            //write profile in tmp file
            using (FileStream fS = new FileStream(_profileFilePath + ".tmp", FileMode.Create, FileAccess.ReadWrite, FileShare.None))
            {
                _node.UpdateProfile();
                _profile.ClientData = SaveProfileSettings();
                _profile.WriteTo(fS);
            }

            File.Delete(_profileFilePath + ".bak");                 //remove old backup file
            File.Move(_profileFilePath, _profileFilePath + ".bak"); //make current profile file as backup file
            File.Move(_profileFilePath + ".tmp", _profileFilePath); //make tmp file as profile file
        }