protected override void EndProcessing()
        {
            AmazonCredentials credentials = AmazonCredentials.Load();

            if (null == credentials)
            {
                credentials = new AmazonCredentials();
            }

            AmazonCredentials.KeyPair keyPair = credentials.KeyPairs.FirstOrDefault(p => string.Equals(this.Name, p.Name, StringComparison.OrdinalIgnoreCase));

            if (null == keyPair)
            {
                keyPair = new AmazonCredentials.KeyPair();
                keyPair.Name = this.Name;
                credentials.KeyPairs.Add(keyPair);
            }

            keyPair.AwsAccessKeyId = this.AwsAccessKeyId;
            keyPair.AwsSecretAccessKey = this.AwsSecretAccessKey;

            if (Default)
            {
                credentials.KeyPairs.ForEach(delegate(AmazonCredentials.KeyPair a) { a.Default = false; });
                keyPair.Default = true;
            }
            
            AmazonCredentials.Save(credentials);
        }
        public static void Save(AmazonCredentials credentials)
        {
            if (null == credentials) throw new ArgumentNullException("credentials", "credentials cannot be null.");

            string parentFolder = Path.GetDirectoryName(CredentialsPath);

            if (!Directory.Exists(parentFolder))
                Directory.CreateDirectory(parentFolder);

            using (FileStream iostr = new FileStream(CredentialsPath, FileMode.Create, FileAccess.Write))
            {
                Serializer.Serialize(iostr, credentials);
            }

            File.Encrypt(CredentialsPath);
        }