mirror of
https://github.com/AndnixSH/APKToolGUI.git
synced 2026-05-04 11:02:27 +00:00
Transition to System.IO.Compression
This commit is contained in:
@@ -84,8 +84,8 @@
|
||||
<Reference Include="DarkNet, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DarkNet.2.3.0\lib\net452\DarkNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DotNetZip, Version=1.16.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll</HintPath>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Build.Framework" />
|
||||
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
||||
@@ -121,8 +121,11 @@
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Immutable.9.0.0\lib\net462\System.Collections.Immutable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.configuration" />
|
||||
@@ -133,14 +136,17 @@
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.9.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Diagnostics.Tracing, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Formats.Nrbf, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Formats.Nrbf.9.0.0\lib\net462\System.Formats.Nrbf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -183,8 +189,8 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
|
||||
@@ -197,24 +203,27 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Resources.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Resources.Extensions.8.0.0\lib\net462\System.Resources.Extensions.dll</HintPath>
|
||||
<Reference Include="System.Reflection.Metadata, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.Metadata.9.0.0\lib\net462\System.Reflection.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Resources.Extensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Resources.Extensions.9.0.0\lib\net462\System.Resources.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Extensions, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll</HintPath>
|
||||
@@ -257,6 +266,9 @@
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -434,6 +446,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="android-thin.ico" />
|
||||
<Content Include="ILLink\ILLink.Descriptors.LibraryBuild.xml" />
|
||||
<None Include="Resources\info.png" />
|
||||
<None Include="Resources\waiting.png" />
|
||||
<None Include="Resources\warning.png" />
|
||||
@@ -477,7 +490,7 @@
|
||||
<Error Condition="!Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Resource.Embedder.2.2.0\build\Resource.Embedder.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Resource.Embedder.2.2.0\build\Resource.Embedder.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Fody.6.8.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.8.0\build\Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Fody.6.9.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.9.0\build\Fody.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
|
||||
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
|
||||
@@ -485,7 +498,7 @@
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\Fody.6.8.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.8.0\build\Fody.targets')" />
|
||||
<Import Project="..\packages\Fody.6.9.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.9.0\build\Fody.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
@@ -493,4 +506,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
Generated
+756
-756
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,6 @@ using System.Collections.Generic;
|
||||
using APKToolGUI.Handlers;
|
||||
using Microsoft.WindowsAPICodePack.Taskbar;
|
||||
using System.Media;
|
||||
using Ionic.Zip;
|
||||
using System.Linq;
|
||||
using System.Windows.Interop;
|
||||
using System.Security.Cryptography;
|
||||
@@ -22,6 +21,7 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using APKToolGUI.Controls;
|
||||
using Dark.Net;
|
||||
using APKEasyTool;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace APKToolGUI
|
||||
{
|
||||
@@ -260,31 +260,35 @@ namespace APKToolGUI
|
||||
{
|
||||
Directory.CreateDirectory(splitPath);
|
||||
|
||||
using (ZipFile zipDest = ZipFile.Read(file))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(file))
|
||||
{
|
||||
bool mainApkFound = false;
|
||||
foreach (ZipEntry entry in zipDest.Entries)
|
||||
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (!mainApkFound && !entry.FileName.Contains("config.") && entry.FileName.EndsWith(".apk"))
|
||||
if (!mainApkFound && !entry.FullName.Contains("config.") && entry.FullName.EndsWith(".apk"))
|
||||
{
|
||||
Debug.WriteLine("Found main APK" + entry.FileName);
|
||||
entry.Extract(splitPath, ExtractExistingFileAction.OverwriteSilently);
|
||||
file = Path.Combine(splitPath, entry.FileName);
|
||||
Debug.WriteLine("Found main APK: " + entry.FullName);
|
||||
string extractPath = Path.Combine(splitPath, entry.FullName);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(extractPath));
|
||||
entry.ExtractToFile(extractPath, true);
|
||||
file = extractPath;
|
||||
mainApkFound = true;
|
||||
}
|
||||
if (entry.FileName.Contains("lib/armeabi-v7a"))
|
||||
|
||||
if (entry.FullName.Contains("lib/armeabi-v7a"))
|
||||
{
|
||||
arch += "armeabi-v7a, ";
|
||||
}
|
||||
if (entry.FileName.Contains("lib/arm64-v8a"))
|
||||
if (entry.FullName.Contains("lib/arm64-v8a"))
|
||||
{
|
||||
arch += "arm64-v8a, ";
|
||||
}
|
||||
if (entry.FileName.Contains("lib/x86"))
|
||||
if (entry.FullName.Contains("lib/x86"))
|
||||
{
|
||||
arch += "x86, ";
|
||||
}
|
||||
if (entry.FileName.Contains("lib/x86_64"))
|
||||
if (entry.FullName.Contains("lib/x86_64"))
|
||||
{
|
||||
arch += "x86_64, ";
|
||||
}
|
||||
|
||||
@@ -8370,9 +8370,6 @@
|
||||
//////////w4AAAcP///////
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>99, 97</value>
|
||||
</data>
|
||||
@@ -8463,6 +8460,12 @@
|
||||
<data name=">>settingsToolStripMenuItem1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>useAPKEditorForDecompilingItem.Name" xml:space="preserve">
|
||||
<value>useAPKEditorForDecompilingItem</value>
|
||||
</data>
|
||||
<data name=">>useAPKEditorForDecompilingItem.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>settingsToolStripMenuItem.Name" xml:space="preserve">
|
||||
<value>settingsToolStripMenuItem</value>
|
||||
</data>
|
||||
@@ -8511,12 +8514,6 @@
|
||||
<data name=">>toolTip1.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>useAPKEditorForDecompilingItem.Name" xml:space="preserve">
|
||||
<value>useAPKEditorForDecompilingItem</value>
|
||||
</data>
|
||||
<data name=">>useAPKEditorForDecompilingItem.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>$this.Name" xml:space="preserve">
|
||||
<value>FormMain</value>
|
||||
</data>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<linker>
|
||||
<assembly fullname="System.Diagnostics.DiagnosticSource">
|
||||
<type fullname="System.Diagnostics.Metrics.MetricsEventSource">
|
||||
<!-- Used by System.Private.CoreLib via reflection to init the EventSource -->
|
||||
<method name="GetInstance" />
|
||||
</type>
|
||||
</assembly>
|
||||
</linker>
|
||||
@@ -1,169 +1,145 @@
|
||||
using Ionic.Zip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace APKToolGUI.Utils
|
||||
{
|
||||
public class ZipUtils
|
||||
{
|
||||
public static void ExtractAllStream(string path, string embeddedZip)
|
||||
{
|
||||
Assembly _assembly = Assembly.GetExecutingAssembly();
|
||||
Stream _zipFileStream = _assembly.GetManifestResourceStream(embeddedZip);
|
||||
using (ZipFile zipFile = ZipFile.Read(_zipFileStream))
|
||||
{
|
||||
zipFile.ExtractAll(path);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFileName(string path, string fileNameContains, string folderContains = "")
|
||||
{
|
||||
using (ZipFile zipDest = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
foreach (ZipEntry entry in zipDest.Entries)
|
||||
{
|
||||
if (entry.FileName.Contains(fileNameContains) && entry.FileName.Contains(folderContains))
|
||||
return Path.GetFileName(entry.FileName);
|
||||
}
|
||||
var entry = archive.Entries
|
||||
.FirstOrDefault(e => e.FullName.Contains(fileNameContains) &&
|
||||
(string.IsNullOrEmpty(folderContains) || e.FullName.Contains(folderContains)));
|
||||
return entry != null ? Path.GetFileName(entry.FullName) : string.Empty;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string GetFileNameWithoutExtension(string path, string fileNameContains, string folderContains = "")
|
||||
{
|
||||
using (ZipFile zipDest = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
foreach (ZipEntry entry in zipDest.Entries)
|
||||
{
|
||||
if (entry.FileName.Contains(fileNameContains) && entry.FileName.Contains(folderContains))
|
||||
return Path.GetFileNameWithoutExtension(entry.FileName);
|
||||
}
|
||||
var entry = archive.Entries
|
||||
.FirstOrDefault(e => e.FullName.Contains(fileNameContains) &&
|
||||
(string.IsNullOrEmpty(folderContains) || e.FullName.Contains(folderContains)));
|
||||
return entry != null ? Path.GetFileNameWithoutExtension(entry.FullName) : string.Empty;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static bool Exists(string path, string fileNameContains, string folderContains = "")
|
||||
{
|
||||
using (ZipFile zipDest = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
foreach (ZipEntry entry in zipDest.Entries)
|
||||
{
|
||||
if (entry.FileName.Contains(fileNameContains) && String.IsNullOrEmpty(folderContains))
|
||||
return true;
|
||||
else if (entry.FileName.Contains(fileNameContains) && entry.FileName.Contains(folderContains))
|
||||
return true;
|
||||
}
|
||||
return archive.Entries.Any(e => e.FullName.Contains(fileNameContains) &&
|
||||
(string.IsNullOrEmpty(folderContains) || e.FullName.Contains(folderContains)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void AddFile(string zipFile, string fileName, string directoryPathInArchive = "")
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(zipFile))
|
||||
using (FileStream fs = new FileStream(zipFile, FileMode.OpenOrCreate))
|
||||
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update))
|
||||
{
|
||||
if (!String.IsNullOrEmpty(directoryPathInArchive))
|
||||
zip.AddFile(fileName, directoryPathInArchive);
|
||||
else
|
||||
zip.AddFile(fileName);
|
||||
zip.Save();
|
||||
string entryName = string.IsNullOrEmpty(directoryPathInArchive) ? fileName : $"{directoryPathInArchive}/{Path.GetFileName(fileName)}";
|
||||
archive.CreateEntryFromFile(fileName, entryName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateFile(string zipFile, string fileName, string directoryPathInArchive = "")
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(zipFile))
|
||||
{
|
||||
if (!String.IsNullOrEmpty(directoryPathInArchive))
|
||||
zip.UpdateFile(fileName, directoryPathInArchive);
|
||||
else
|
||||
zip.UpdateFile(fileName);
|
||||
zip.Save();
|
||||
}
|
||||
RemoveFile(zipFile, fileName);
|
||||
AddFile(zipFile, fileName, directoryPathInArchive);
|
||||
}
|
||||
|
||||
public static void RemoveFile(string zipFile, string fileName)
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(zipFile))
|
||||
using (FileStream fs = new FileStream(zipFile, FileMode.OpenOrCreate))
|
||||
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update))
|
||||
{
|
||||
bool chkresult2 = zip.Any(entry => entry.FileName.Contains(fileName));
|
||||
if (chkresult2)
|
||||
{
|
||||
zip.RemoveEntry(fileName);
|
||||
zip.Save();
|
||||
}
|
||||
var entry = archive.Entries.FirstOrDefault(e => e.FullName.Contains(fileName));
|
||||
entry?.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExtractFile(string path, string fileName, string destination)
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
bool chkresult2 = zip.Any(entry => entry.FileName.Contains(fileName));
|
||||
if (chkresult2)
|
||||
{
|
||||
zip.FlattenFoldersOnExtract = true;
|
||||
ZipEntry e = zip[fileName];
|
||||
e.Extract(destination, ExtractExistingFileAction.OverwriteSilently);
|
||||
}
|
||||
var entry = archive.Entries.FirstOrDefault(e => e.FullName.Contains(fileName));
|
||||
entry?.ExtractToFile(Path.Combine(destination, Path.GetFileName(entry.FullName)), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExtractAll(string path, string destination, bool flattenFoldersOnExtract = false)
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
zip.FlattenFoldersOnExtract = flattenFoldersOnExtract;
|
||||
zip.ExtractAll(destination, ExtractExistingFileAction.OverwriteSilently);
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
string fullPath = flattenFoldersOnExtract
|
||||
? Path.Combine(destination, Path.GetFileName(entry.FullName))
|
||||
: Path.Combine(destination, entry.FullName);
|
||||
string directoryPath = Path.GetDirectoryName(fullPath);
|
||||
if (!string.IsNullOrEmpty(directoryPath)) Directory.CreateDirectory(directoryPath);
|
||||
entry.ExtractToFile(fullPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddDirectory(string path, string fileName, string directoryPathInArchive = "")
|
||||
public static void AddDirectory(string path, string directoryPath, string directoryPathInArchive = "")
|
||||
{
|
||||
ZipFile zip = new ZipFile();
|
||||
if (!String.IsNullOrEmpty(directoryPathInArchive))
|
||||
zip.AddDirectory(fileName, directoryPathInArchive);
|
||||
else
|
||||
zip.AddDirectory(fileName);
|
||||
zip.Save(path);
|
||||
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
|
||||
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update))
|
||||
{
|
||||
foreach (string filePath in Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string entryName = string.IsNullOrEmpty(directoryPathInArchive)
|
||||
? filePath.Substring(directoryPath.Length + 1)
|
||||
: Path.Combine(directoryPathInArchive, filePath.Substring(directoryPath.Length + 1));
|
||||
archive.CreateEntryFromFile(filePath, entryName.Replace("\\", "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateDirectory(string path, string dirName, string directoryPathInArchive = "")
|
||||
public static void UpdateDirectory(string path, string directoryPath, string directoryPathInArchive = "")
|
||||
{
|
||||
using (ZipFile zip = ZipFile.Read(path))
|
||||
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
|
||||
using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update))
|
||||
{
|
||||
if (!String.IsNullOrEmpty(directoryPathInArchive))
|
||||
zip.UpdateDirectory(dirName, directoryPathInArchive);
|
||||
else
|
||||
zip.UpdateDirectory(dirName);
|
||||
zip.Save();
|
||||
foreach (string filePath in Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string entryName = string.IsNullOrEmpty(directoryPathInArchive)
|
||||
? filePath.Substring(directoryPath.Length + 1)
|
||||
: Path.Combine(directoryPathInArchive, filePath.Substring(directoryPath.Length + 1));
|
||||
RemoveFile(path, entryName.Replace("\\", "/"));
|
||||
archive.CreateEntryFromFile(filePath, entryName.Replace("\\", "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExtractDirectory(string path, string folderName, string destination, bool flattenFoldersOnExtract = false)
|
||||
{
|
||||
//using (ZipFile zip = ZipFile.Read(path))
|
||||
//{
|
||||
// bool chkresult2 = zip.Any(entry => entry.FileName.Contains(folderName));
|
||||
// if (chkresult2)
|
||||
// {
|
||||
// zip.FlattenFoldersOnExtract = flattenFoldersOnExtract;
|
||||
// zip.ExtractSelectedEntries("name = *", folderName, destination, ExtractExistingFileAction.OverwriteSilently);
|
||||
// }
|
||||
//}
|
||||
using (ZipFile zip = ZipFile.Read(path))
|
||||
using (ZipArchive archive = ZipFile.OpenRead(path))
|
||||
{
|
||||
zip.FlattenFoldersOnExtract = flattenFoldersOnExtract;
|
||||
foreach (ZipEntry e in zip.Where(x => x.FileName.Contains(folderName)))
|
||||
foreach (ZipArchiveEntry entry in archive.Entries.Where(e => e.FullName.Contains(folderName)))
|
||||
{
|
||||
e.Extract(destination, ExtractExistingFileAction.OverwriteSilently);
|
||||
string extractPath = flattenFoldersOnExtract
|
||||
? Path.Combine(destination, Path.GetFileName(entry.FullName))
|
||||
: Path.Combine(destination, entry.FullName);
|
||||
|
||||
string directoryPath = Path.GetDirectoryName(extractPath);
|
||||
if (!string.IsNullOrEmpty(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
|
||||
entry.ExtractToFile(extractPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -308,7 +308,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WinCopies.WindowsAPICodePack.Win32Native" publicKeyToken="ac0f4cf54a027a4d" culture="neutral" />
|
||||
@@ -320,7 +320,15 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.HashCode" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<packages>
|
||||
<package id="Costura.Fody" version="5.7.0" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="DarkNet" version="2.3.0" targetFramework="net48" />
|
||||
<package id="DotNetZip" version="1.16.0" targetFramework="net48" />
|
||||
<package id="Fody" version="6.8.0" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="Fody" version="6.9.0" targetFramework="net48" developmentDependency="true" />
|
||||
<package id="Microsoft.Bcl.HashCode" version="6.0.0" targetFramework="net48" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="7.0.4" targetFramework="net48" />
|
||||
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net48" />
|
||||
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.5" targetFramework="net48" />
|
||||
@@ -15,14 +15,16 @@
|
||||
<package id="Resource.Embedder" version="2.2.0" targetFramework="net48" />
|
||||
<package id="ResourceLoader" version="3.3.1" targetFramework="net48" />
|
||||
<package id="System.AppContext" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||
<package id="System.Buffers" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Collections.Immutable" version="9.0.0" targetFramework="net48" />
|
||||
<package id="System.Console" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="8.0.0" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="9.0.0" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Formats.Nrbf" version="9.0.0" targetFramework="net48" />
|
||||
<package id="System.Globalization" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="net48" />
|
||||
@@ -32,19 +34,20 @@
|
||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||
<package id="System.Memory" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.Net.Http" version="4.3.4" targetFramework="net48" />
|
||||
<package id="System.Net.Primitives" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net48" />
|
||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Reflection.Metadata" version="9.0.0" targetFramework="net48" />
|
||||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Resources.Extensions" version="8.0.0" targetFramework="net48" />
|
||||
<package id="System.Resources.Extensions" version="9.0.0" targetFramework="net48" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Runtime" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.Extensions" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net48" />
|
||||
@@ -60,6 +63,7 @@
|
||||
<package id="System.Threading" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net48" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net48" />
|
||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net48" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user