private bool CreateProfile() { if (!ValidateEntries()) { return(false); } FileInfo file; try { file = new FileInfo(txtFilePath.Text); } catch { MessageBox.Show(GlobalStrings.DlgProfile_YouMustEnterValidProfilePath, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!file.Directory.Exists) { try { file.Directory.Create(); } catch { MessageBox.Show(GlobalStrings.DlgProfile_FailedToCreateParentDirectory, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } Profile profile = new Profile(); SaveModifiables(profile); Profile.GenerateDefaultAutoCatSet(profile.AutoCats); try { profile.Save(file.FullName); } catch (ApplicationException e) { MessageBox.Show(e.Message, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } this.Profile = profile; return(true); }
private bool SaveProfile(Profile p, bool doSave) { if (!doSave) { WriteLine("Skipping profile save."); return(true); } Write("Saving profile..."); bool success = false; try { p.Save(); success = true; } catch (Exception e) { WriteLine("Error saving profile: " + e.Message); Program.Logger.WriteException("Automatic mode: Error saving profile.", e); } if (success) { WriteLine("Saved."); } return(success); }
private bool CreateProfile() { if( !ValidateEntries() ) { return false; } FileInfo file; try { file = new FileInfo( txtFilePath.Text ); } catch { MessageBox.Show( GlobalStrings.DlgProfile_YouMustEnterValidProfilePath, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error ); return false; } if( !file.Directory.Exists ) { try { file.Directory.Create(); } catch { MessageBox.Show( GlobalStrings.DlgProfile_FailedToCreateParentDirectory, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error ); return false; } } Profile profile = new Profile(); SaveModifiables( profile ); Profile.GenerateDefaultAutoCatSet( profile.AutoCats ); try { profile.Save( file.FullName ); } catch( ApplicationException e ) { MessageBox.Show( e.Message, GlobalStrings.DBEditDlg_Error, MessageBoxButtons.OK, MessageBoxIcon.Error ); return false; } this.Profile = profile; return true; }
private bool SaveProfile( Profile p, bool doSave ) { if( !doSave ) { WriteLine( "Skipping profile save." ); return true; } Write( "Saving profile..." ); bool success = false; try { p.Save(); success = true; } catch( Exception e ) { WriteLine( "Error saving profile: " + e.Message ); Program.Logger.WriteException( "Automatic mode: Error saving profile.", e ); } if( success ) WriteLine( "Saved." ); return success; }