public VarImportCommand(TextBox txtVarName, string currentVarValues, string fileName, DgvHandler dgvHandler) { this.txtVarName = txtVarName; this.curVarValues = currentVarValues; this.variable = new EnvironmentVariable(); EnvironmentSnapshotManager.LoadVariable(fileName, ref variable); this.dgvHandler = dgvHandler; GetValuesToImport(); }
private void ExportEnvironmentVariable() { try { saveFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString(); if (saveFileDialog.ShowDialog() == DialogResult.OK) { EnvironmentVariable envVar = new EnvironmentVariable(); envVar.Name = txtVariableName.Text; envVar.Value = EnvironmentVariableValue().ToString(); EnvironmentSnapshotManager.SaveVariable(saveFileDialog.FileName, ref envVar); MessageBox.Show("'" + txtVariableName.Text + "' successfully exported to " + saveFileDialog.FileName + " file.", "Export Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!"); } }