Am使用TransferManager
将Blob从一个容器复制到另一个容器。
CloudStorageAccount sourceStorageAccount = CloudStorageAccount.Parse(@"source storage account connection string");
CloudStorageAccount destStorageAccount = CloudStorageAccount.Parse(@"destination storage account connection string");
CloudBlobClient sourceBlobClient = sourceStorageAccount.CreateCloudBlobClient();
CloudBlobClient destBlobClient = destStorageAccount.CreateCloudBlobClient();
var sourceContainer = sourceBlobClient.GetContainerReference("sourceContainer");
var destContainer = destBlobClient.GetContainerReference("destContainer");
CloudBlockBlob sourceBlob = sourceContainer.GetBlockBlobReference("copy.txt");
CloudBlockBlob targetBlob = destContainer.GetBlockBlobReference("copy.txt");
TransferManager.CopyAsync(sourceBlob, targetBlob, true).Wait();
但是,当文件位于目标位置时,它将引发错误说明
“跳过的文件 \“ https://sourceabcd.blob.core.windows.net/sourcecontainer/test1.txt \” 因为目标 \“ https://sourceabcd.blob.core.windows.net/destcontainer/test1.txt \” 已经存在。“} System.Exception {Microsoft.WindowsAzure.Storage.DataMovement.TransferSkippedException
如果目的地中存在文件,是否可以选择覆盖文件?
答案 0 :(得分:1)