From 5ebb6c416588a556a25d672c44e9b881bbea75fd Mon Sep 17 00:00:00 2001 From: Aliaksandr Rasolka Date: Fri, 7 Jun 2024 19:14:54 +0300 Subject: [PATCH] Update BinaryService.cs --- WebDriverManager/Services/Impl/BinaryService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WebDriverManager/Services/Impl/BinaryService.cs b/WebDriverManager/Services/Impl/BinaryService.cs index d7229c5..231ca96 100644 --- a/WebDriverManager/Services/Impl/BinaryService.cs +++ b/WebDriverManager/Services/Impl/BinaryService.cs @@ -190,13 +190,14 @@ protected string UnZip(string path, string destination, string name) if (zipEntry.Name.EndsWith(name) && zipEntry.IsFile) { byte[] buffer = new byte[4096]; - Stream zipStream = zip.GetInputStream(zipEntry); - - // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size - // of the file, but does not waste memory. - using (FileStream streamWriter = File.Create(destination)) + using (Stream zipStream = zip.GetInputStream(zipEntry)) { - StreamUtils.Copy(zipStream, streamWriter, buffer); + // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size + // of the file, but does not waste memory. + using (FileStream streamWriter = File.Create(destination)) + { + StreamUtils.Copy(zipStream, streamWriter, buffer); + } } } }