Hello,
I’m trying to get a zip to save and read. I need to protect this zip with some password.
I found DotNetZip, I made some test console app it works like I want. Then I tried to transfer that code to Unity. I get correct import, scripts can get content of the dll.
But i get this error:
NullReferenceException: Object reference not set to an instance of an object
Ionic.Zip.ZipEntry.GetEncodedFileNameBytes () (at <92c46b229f654faaafd572a1bd450a33>:0)
Ionic.Zip.ZipEntry.WriteHeader (System.IO.Stream s, System.Int32 cycle) (at <92c46b229f654faaafd572a1bd450a33>:0)
Ionic.Zip.ZipEntry.Write (System.IO.Stream s) (at <92c46b229f654faaafd572a1bd450a33>:0)
Ionic.Zip.ZipFile.Save () (at <92c46b229f654faaafd572a1bd450a33>:0)
Ionic.Zip.ZipFile.Save (System.String fileName) (at <92c46b229f654faaafd572a1bd450a33>:0)
I tried to add some dependency from DotNetZip
but it doesn’t work. Can someone help me ?
Any other methods will be appreciated. Thanks in advance.
My test code:
public static void MakeZip(string sourceDirectoryPath, string password, string destinyPath, string fileName = "package")
{
string extension = ".ext";
using (ZipFile zip = new ZipFile())
{
zip.Password = password;
zip.AddDirectory(sourceDirectoryPath);
zip.Save(destinyPath + fileName + extension);
}
}
public static void GetDataFromZip(string sourcePackagePath, string password, string destinyPath)
{
using (ZipFile zip = ZipFile.Read(sourcePackagePath))
{
zip.Password = password;
zip.ExtractAll(destinyPath, ExtractExistingFileAction.DoNotOverwrite);
}
}
[INFO]
Unity 2019.4.8f1