@@ -397,14 +397,42 @@ To learn more about each of these authorization mechanisms, see [Choose how to a
397
397
398
398
### Example: Copy files using the File Shares client library
399
399
400
- The following code example shows how to copy a file to another file :
400
+ You can copy files within a file share or between file shares by using the following method :
401
401
402
- ```csharp
403
- ```
402
+ - [StartCopyAsync](/dotnet/api/azure.storage.files.shares.sharefileclient.startcopyasync)
403
+
404
+ You can copy a file to a destination blob by using the following method from a `BlobClient` object:
405
+
406
+ - [StartCopyFromUriAsync](/dotnet/api/azure.storage.blobs.specialized.blobbaseclient.startcopyfromuriasync)
404
407
405
- The following code example shows how to copy a file to a blob :
408
+ The following code example shows how to copy a file to a file in another file share :
406
409
407
410
```csharp
411
+ string accountName = "<account-name>";
412
+ string srcShareName = "src-file-share";
413
+ string destShareName = "dest-file-share";
414
+ string srcFilePath = "src/path/to/file";
415
+ string destFilePath = "dest/path/to/file";
416
+
417
+ TokenCredential tokenCredential = new DefaultAzureCredential();
418
+
419
+ ShareFileClient srcShareFileClient = new(
420
+ new Uri($"https://{accountName}.file.core.windows.net/{srcShareName}/{srcFilePath}"),
421
+ tokenCredential);
422
+
423
+ ShareClientOptions options = new()
424
+ {
425
+ ShareTokenIntent = ShareTokenIntent.Backup,
426
+ };
427
+
428
+ ShareFileClient destShareFileClient = new(
429
+ new Uri($"https://{accountName}.file.core.windows.net/{destShareName}/{destFilePath}"),
430
+ tokenCredential,
431
+ options);
432
+
433
+ // Copy the file from the source share to the destination share
434
+
435
+ await destShareFileClient.StartCopyAsync(srcShareFileClient.Uri);
408
436
```
409
437
410
438
## Manage Azure Files resources using the Azure Storage management libraries
0 commit comments