private void cmdSave_Click(object sender, EventArgs e) { // check if exists string filename = folderPath + UserType.Description + ".xml"; if (File.Exists(filename)) { if (MessageBox.Show("This user type already exists, do you want to overwrite?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.Yes) { // overwrite? File.WriteAllText(filename, UserType.SaveToXML()); } else { } } }
private void SaveUserTypes() { Respondent r = UserTypeDefs.Create6E2UT1(); File.WriteAllText(folderPath + "6E2 User type 1.xml", r.SaveToXML()); r = UserTypeDefs.Create6E2UT2(); File.WriteAllText(folderPath + "6E2 User type 2.xml", r.SaveToXML()); r = UserTypeDefs.Create6E2UT3(); File.WriteAllText(folderPath + "6E2 User type 3.xml", r.SaveToXML()); r = UserTypeDefs.Create6E2UT4(); File.WriteAllText(folderPath + "6E2 User type 4.xml", r.SaveToXML()); r = UserTypeDefs.CreateESUT1(); File.WriteAllText(folderPath + "ES2.5 User type 1.xml", r.SaveToXML()); r = UserTypeDefs.CreateESUT2(); File.WriteAllText(folderPath + "ES2.5 User type 2.xml", r.SaveToXML()); r = UserTypeDefs.CreateESUT3(); File.WriteAllText(folderPath + "ES2.5 User type 3.xml", r.SaveToXML()); r = UserTypeDefs.CreateESUT4(); File.WriteAllText(folderPath + "ES2.5 User type 4.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_NSH_User(); File.WriteAllText(folderPath + "JP3 Nonsmoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_NSNH_User(); File.WriteAllText(folderPath + "JP3 Nonsmoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_NSNH_User(); File.WriteAllText(folderPath + "JP3 Nonsmoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_SH_User(); File.WriteAllText(folderPath + "JP3 Smoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_SNH_User(); File.WriteAllText(folderPath + "JP3 Smoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP3_XSH_User(); File.WriteAllText(folderPath + "JP3 ExSmoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_NSH_User(); File.WriteAllText(folderPath + "JP2 Nonsmoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_NSNH_User(); File.WriteAllText(folderPath + "JP2 Nonsmoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_NSNH_User(); File.WriteAllText(folderPath + "JP2 Nonsmoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_SH_User(); File.WriteAllText(folderPath + "JP2 Smoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_SNH_User(); File.WriteAllText(folderPath + "JP2 Smoker NonHTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateJP2_XSH_User(); File.WriteAllText(folderPath + "JP2 ExSmoker HTP User.xml", r.SaveToXML()); r = UserTypeDefs.CreateNLD2_UT1(); File.WriteAllText(folderPath + "NLD2 UT1.xml", r.SaveToXML()); r = UserTypeDefs.CreateNLD2_UT2(); File.WriteAllText(folderPath + "NLD2 UT2.xml", r.SaveToXML()); r = UserTypeDefs.CreateNLD2_UT3(); File.WriteAllText(folderPath + "NLD2 UT3.xml", r.SaveToXML()); r = UserTypeDefs.CreateNLD2_UT4(); File.WriteAllText(folderPath + "NLD2 UT4.xml", r.SaveToXML()); }