@@ -254,7 +254,7 @@ public override IAsyncOperation<BaseStorageFile> CopyAsync(IStorageFolder destin
254
254
else
255
255
{
256
256
var destFile = await destFolder . CreateFileAsync ( desiredNewName , option . Convert ( ) ) ;
257
- using var outStream = await destFile . OpenStreamForWriteAsync ( ) ;
257
+ await using var outStream = await destFile . OpenStreamForWriteAsync ( ) ;
258
258
await SafetyExtensions . WrapAsync ( ( ) => zipFile . ExtractFileAsync ( entry . Index , outStream ) , async ( _ , exception ) =>
259
259
{
260
260
await destFile . DeleteAsync ( ) ;
@@ -281,7 +281,7 @@ public override IAsyncAction CopyAndReplaceAsync(IStorageFile fileToReplace)
281
281
}
282
282
283
283
using var hDestFile = fileToReplace . CreateSafeFileHandle ( FileAccess . ReadWrite ) ;
284
- using ( var outStream = new FileStream ( hDestFile , FileAccess . Write ) )
284
+ await using ( var outStream = new FileStream ( hDestFile , FileAccess . Write ) )
285
285
{
286
286
await zipFile . ExtractFileAsync ( entry . Index , outStream ) ;
287
287
}
@@ -323,14 +323,15 @@ public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption
323
323
}
324
324
using ( var ms = new MemoryStream ( ) )
325
325
{
326
- using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . Read ) )
326
+ await using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . Read ) )
327
327
{
328
328
SevenZipCompressor compressor = new SevenZipCompressor ( ) { CompressionMode = CompressionMode . Append } ;
329
329
compressor . SetFormatFromExistingArchive ( archiveStream ) ;
330
330
var fileName = IO . Path . GetRelativePath ( containerPath , IO . Path . Combine ( IO . Path . GetDirectoryName ( Path ) , desiredName ) ) ;
331
331
await compressor . ModifyArchiveAsync ( archiveStream , new Dictionary < int , string > ( ) { { index , fileName } } , Credentials . Password , ms ) ;
332
332
}
333
- using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . ReadWrite ) )
333
+
334
+ await using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . ReadWrite ) )
334
335
{
335
336
ms . Position = 0 ;
336
337
await ms . CopyToAsync ( archiveStream ) ;
@@ -371,13 +372,13 @@ public override IAsyncAction DeleteAsync(StorageDeleteOption option)
371
372
}
372
373
using ( var ms = new MemoryStream ( ) )
373
374
{
374
- using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . Read ) )
375
+ await using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . Read ) )
375
376
{
376
377
SevenZipCompressor compressor = new SevenZipCompressor ( ) { CompressionMode = CompressionMode . Append } ;
377
378
compressor . SetFormatFromExistingArchive ( archiveStream ) ;
378
379
await compressor . ModifyArchiveAsync ( archiveStream , new Dictionary < int , string > ( ) { { index , null } } , Credentials . Password , ms ) ;
379
380
}
380
- using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . ReadWrite ) )
381
+ await using ( var archiveStream = await OpenZipFileAsync ( FileAccessMode . ReadWrite ) )
381
382
{
382
383
ms . Position = 0 ;
383
384
await ms . CopyToAsync ( archiveStream ) ;
@@ -505,7 +506,7 @@ private StreamedFileDataRequestedHandler ZipDataStreamingHandler(string name)
505
506
}
506
507
else
507
508
{
508
- using ( var outStream = request . AsStreamForWrite ( ) )
509
+ await using ( var outStream = request . AsStreamForWrite ( ) )
509
510
{
510
511
await zipFile . ExtractFileAsync ( entry . Index , outStream ) ;
511
512
}
0 commit comments