Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NBitcoin.TestFramework/NBitcoin.TestFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

Expand Down
13 changes: 12 additions & 1 deletion NBitcoin.TestFramework/NodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,18 @@ public static string EnsureDownloaded(NodeDownloadData downloadData)

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ZipFile.ExtractToDirectory(zip, extractDirectory);
// From https://feedback.telerik.com/document-processing/1518667-ziplibrary-allow-zipfile-extracttodirectory-to-overwrite-existing-files-when-extract-zip

using var source = ZipFile.Open(zip, ZipArchiveMode.Read, null);
foreach (var entry in source.Entries)
{
var fullPath = Path.GetFullPath(Path.Combine(extractDirectory, entry.FullName));

if (Path.GetFileName(fullPath).Length == 0) continue;
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// The boolean parameter determines whether an existing file that has the same name as the destination file should be overwritten
entry.ExtractToFile(fullPath, true);
}
}
else
{
Expand Down