コード例 #1
0
        private void ImportToolButtonClick(object sender, EventArgs e)
        {
            KeyData key           = null;
            string  indexFileName = null;
            var     dlg           = new OpenFileDialog
            {
                Title           = "Import Backup Index File...",
                DefaultExt      = "index",
                Filter          = "Backup Index files (*.index)|*.index|All files (*.*)|*.*",
                CheckFileExists = true,
                Multiselect     = false,
                ValidateNames   = true
            };

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                indexFileName = dlg.FileName;
            }
            else
            {
                return;
            }
            dlg = new OpenFileDialog
            {
                Title            = "Import Key This Backup (Wrong key will not produce a good restore!)",
                DefaultExt       = "key",
                Filter           = "Key files (*.key)|*.key|All files (*.*)|*.*",
                InitialDirectory = GetSettingsFolder(),
                CheckFileExists  = true,
                Multiselect      = false,
                ValidateNames    = true
            };
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                key = KeyData.Load(dlg.FileName);
            }
            else
            {
                return;
            }
            var indexName = Path.GetFileNameWithoutExtension(indexFileName);
            var plan      = BackupPlan.BackupPlan.ImportFromIndexFile(key, indexFileName, AddLogEntry);

            AddPlan(plan);
        }