Depressurizer.DlgProfile.CreateProfile C# (CSharp) Method

CreateProfile() private method

private CreateProfile ( ) : bool
return bool
        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;
        }