- Home /
Unable To Unzip File After Build
Hello, I have a simple unzip class built and it works fine while I test in the editor, but once it is built, it appears that the script will not run. Here is some code I have. I am using the Ionic.zip.dll.
ZipHelper.cs:
using UnityEngine;
using System.Collections;
using Ionic.Zip;
public class ZipHelper {
public static string ExtractZip(string filePath, string destFolder){
using(ZipFile zip = ZipFile.Read(filePath)){
// extracting entries
foreach(ZipEntry z in zip){
z.Extract(destFolder, ExtractExistingFileAction.OverwriteSilently);
}
}
}
}
Where It Is Called:
ZipHelper.ExtractZip(DirectoryHelper.getDownloadPath() + "/forgesrc.zip", Directory.GetCurrentDirectory());
I have already tried running the program as administrator to avoid any r/w issues. This does not work either, but the referenced DLL does appear to be loading fine in the log file. No other errors or weird events show up in the log file so i am about as confused as i can get.
Note the folders inside your Assets folder don't exist in a build.
yes, the directory is made and filled after the program starts. it does not need to compile with the directories
I doubt this is the problem, but consider using Application.persistentDataPath as the location.
i just tried, but still no luck. It is weird because i know its not the dll anymore because i got the source code of sharpziplib and used that with no luck. Unfortunately it looks like it is just an inability to open the zip file. the script breaks right at the "using(ZipFile zip = ZipFile.Read(filePath)){" line.
Answer by edmiester777 · Dec 26, 2013 at 05:24 AM
Well I Figured out the problem if anyone has an issue with dll imports not working after build, it is because some dependency dll files are missing from unity's build. Navigate to: C:\\Program Files (x86)\\Unity\\\Editor\\\Data\\\Mono\\\lib\\\mono\\unity and copy all of the I18N.dlls. This will fix any incompatability issues
Answer by KittyCrafting · Dec 24, 2013 at 12:47 AM
is forgesrc.zip in the same folder as the program? or it could mean in your local disk.
Well it downloads into a folder next to the exe file. That folder is called downloads. Should i make it download to the resources folder? The directory is created when the application starts, and that works fine, downloading the file works, its just the unzipping that doesn't work.