This is in C#, use an online converter.
Considering nobody has answered your question yet, let me do this.
You'll have to use a library that I will link you to, use a youtube tutorial about adding libraries to your project.
You must login or register to view this content.
Make sure you reference the
System.IO assembly and the
DotNetZip library.
First of all extracting the input zip file to a temporary location:-
private void ExtractArchive(string archiveName, string directory)
{
using (ZipFile zipFile = ZipFile.Read(archiveName))
foreach (ZipEntry e in zipFile)
e.Extract(directory, ExtractExistingFileAction.OverwriteSilently);
}
Example usage:
ExtractArchive("xray.zip", Directory.GetCurrentDirectory());
Now we just have to add these files to our JAR archive.
private void InsertFolderContentsIntoArchive(string archiveName, string directory)
{
using (ZipFile zipFile = ZipFile.Read(archiveName))
{
string[] directoryContents = Directory.GetFiles(directory);
foreach(string s in directoryContents);
zipFile.AddFile(directoryContents);
zipFile.Save();
}
}
Example usage: InsertFolderContentsIntoArchive("location/to/.minecraft/bin/minecraft.jar", "C:/example/folder");
Note: InsertFolderContentsIntoArchive only gets the files from the directory's root, none of the files inside of sub folders will be added. If you want it to add folders and sub-folder content then just use
Directory.GetDirectories(string directory) and then add the folder results from it before scanning those directories and so on.
I rewrote portions of the code I took from the DotNetZip website.