private void ExportINIButton_Click(object sender, EventArgs e) { bool autoSaveSuccess = false; string autoSaveName = ""; bool preferAutoSave = true; // make this configurable later. if (preferAutoSave) { if (modFolder != null && modFolder.Length > 0) { // try doing auto-export Directory.CreateDirectory(modFolder); if (Directory.Exists(modFolder)) { autoSaveSuccess = true; autoSaveName = Path.Combine(modFolder, fileName); } } } if (autoSaveSuccess) { StructConverter.ExportINI(iniData, itemsToExport, autoSaveName); MessageBox.Show("Export Complete!"); Hide(); } else { using (SaveFileDialog fileDialog = new SaveFileDialog() { DefaultExt = "ini", Filter = "INI files|*.ini", InitialDirectory = modFolder, RestoreDirectory = true }) { fileDialog.InitialDirectory = modFolder; fileDialog.FileName = fileName; if (fileDialog.ShowDialog(this) == DialogResult.OK) { StructConverter.ExportINI(iniData, itemsToExport, fileDialog.FileName); } } } }