- Home /
Error creating a zip file in iOS
I'm trying to create a zip file, it works fine in editor but i get an error in an iOS build
Here's my code:
void CompressFiles(IList<string> files, string path) {
var stream = new ZipOutputStream(File.Open(path, FileMode.Create));
stream.UseZip64 = UseZip64.Off;
foreach (var file in files) {
var fi = new FileInfo(file);
var filename = Path.GetFileName(file);
var entry = new ZipEntry(filename);
entry.DateTime = fi.LastWriteTime;
entry.Size = fi.Length;
stream.PutNextEntry(entry);
var buffer = new byte[4096];
using (var streamReader = File.OpenRead(file)) {
StreamUtils.Copy(streamReader, stream, buffer);
}
stream.CloseEntry();
}
stream.Close();
Debug.Log($"Files compressed to {path}");
}
And this is the error I'm getting on xcode:
NotSupportedException: Encoding 437 data could not be found. Make sure you have correct international codeset assembly installed and enabled. at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x00000] in :0 > at System.IO.Compression.ZipStorer..cctor > () [0x00000] in > :0 > at Pomelo.BugReporter.CompressFiles > (System.Collections.Generic.IList`1[T] > files, System.String path) [0x00000] > in > :0 > at Pomelo.BugReporter+d_11.MoveNext > () [0x00000] in > :0 > at UnityEngine.SetupCoroutine.InvokeMoveNext > (System.Collections.IEnumerator > enumerator, System.IntPtr > returnValueAddress) [0x00000] in > :0 > Rethrow as TypeInitializationException: The type > initializer for > 'System.IO.Compression.ZipStorer' > threw an exception. > at Pomelo.BugReporter.CompressFiles > (System.Collections.Generic.IList`1[T] > files, System.String path) [0x00000] > in > :0 > at Pomelo.BugReporter+d_11.MoveNext > () [0x00000] in > :0 > at UnityEngine.SetupCoroutine.InvokeMoveNext > (System.Collections.IEnumerator > enumerator, System.IntPtr > returnValueAddress) [0x00000] in > :0
Have you try SharpZip from github? I also modified as .Net3.5 version for my small tool F$$anonymous$$ETP STREA$$anonymous$$.
Your answer
![](https://koobas.hobune.stream/wayback/20220612235610im_/https://answers.unity.com/themes/thub/images/avi.jpg)