/// <summary>
/// Replaces the destination file with the content of this file and then deletes the orignial file. If a backupFile is specifed then the content of destination file is
/// backup to it.
/// </summary>
/// <param name="destFile">Where the contents of this file will be copy to.</param>
/// <param name="backupFile">If specified the destFile is backup to it.</param>
/// <exception cref="T:System.ArgumentException"></exception>
/// <exception cref="T:System.IO.IOException"></exception>
/// <exception cref="T:System.Net.WebException"></exception>
/// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
/// <returns>S3FileInfo of the destination file.</returns>
public S3FileInfo Replace(S3FileInfo destFile, S3FileInfo backupFile)
{
if (string.Equals(this.BucketName, destFile.BucketName) && string.Equals(this.ObjectKey, destFile.ObjectKey))
{
throw new ArgumentException("Destination file can not be the same as the source file when doing a replace.", "destFile");
}
if (backupFile != null)
{
destFile.CopyTo(backupFile, true);
}
S3FileInfo ret = CopyTo(destFile, true);
Delete();
return ret;
}