Amazon.S3.IO.S3FileInfo.CopyTo C# (CSharp) Method

CopyTo() public method

Copies this file to the target directory. If the file already exists in S3 than an ArgumentException is thrown.
If the directory does not exist. If the file already exists in S3.
public CopyTo ( S3DirectoryInfo dir ) : S3FileInfo
dir S3DirectoryInfo Target directory where to copy the file to.
return S3FileInfo
        public S3FileInfo CopyTo(S3DirectoryInfo dir)
        {
            return CopyTo(dir, false);
        }

Same methods

S3FileInfo::CopyTo ( S3DirectoryInfo dir, bool overwrite ) : S3FileInfo
S3FileInfo::CopyTo ( S3FileInfo file ) : S3FileInfo
S3FileInfo::CopyTo ( S3FileInfo file, bool overwrite ) : S3FileInfo
S3FileInfo::CopyTo ( string newBucket, string newKey ) : S3FileInfo
S3FileInfo::CopyTo ( string newBucket, string newKey, bool overwrite ) : S3FileInfo

Usage Example

Example #1
0
 /// <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;
 }
All Usage Examples Of Amazon.S3.IO.S3FileInfo::CopyTo