Post: Visual basic help
01-02-2013, 12:57 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Can anybody help me with something I want to be able to use an openfiledialog to select a zip that copy its files into a minecraft.jar folder to make a mod installer from there i could start adding features myself.
(adsbygoogle = window.adsbygoogle || []).push({});
01-08-2013, 08:40 PM #2
Pure_
Do a barrel roll!
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.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo