/// <summary> /// saves a file. /// </summary> /// <param name="filename">"" to ask user to select a new file, or provide a filename to save directly</param> /// <param name="saveMe">The Profile group to save.</param> /// <returns>returns true if the user saved, or false if the user canceled.</returns> private bool SaveFile(string filename, ProfileGroup saveMe) { if (saveMe.Items.Count == 0) { ShowErrorCheckMessage("A Profile Group must contain one or more Profiles.", saveMe.Name, true); return(false); } if (!ErrorCheckProfileGroup(saveMe)) { return(false); } if (filename == "") { saveFileDialog.FileName = groupEditor.ProfileGroup.Name + ".xml"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { filename = saveFileDialog.FileName; } else { saveFileDialog.FileName = ""; return(false); } } try { saveMe.SaveToFile(filename); return(true); } catch (Exception ex) { MessageBox.Show(this, "An error occurred while saving the Profile Group!" + Environment.NewLine + Environment.NewLine + ex.Message, "Error while saving!", MessageBoxButtons.OK, MessageBoxIcon.Error); saveFileDialog.FileName = ""; return(false); } }
public void PutProfileGroup(ProfileGroup profileGroup) { profileGroup.SaveToFile(profileGroup.Name); }