Hi everyone, I have a config file in xml which is zipped. And I would like to unzip it and use its content in javascript at runtime. Could anyone show me the way to do that ? Thanks
Hello, Bonjour ! I implemented such a solution. I used the library provided in Unity called ICSharpCode.SharpZipLib.dll. You can find lot of samples on the net, it's not a Unity library. Copy the dll into your assets directory and the clause using ICSharpCode.SharpZipLib.Zip; Code (csharp): void unzip() { try { string strRealzip = "myzip.zip"; ICSharpCode.SharpZipLib.Zip.ZipInputStream s = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(strRealzip)); ZipEntry theEntry; //loop on all the files in the zip file while ((theEntry = s.GetNextEntry()) != null) { string strFileName = Path.GetFileName(theEntry.Name); if (strFileName != string.Empty) { using (FileStream streamWriter = File.Create(strFileName)) { int size = 2048; byte[] data = new byte[2048]; while (true) { size = s.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } } } }//while } catch(System.Exception ex) { Debug.Log("Excep - " + ex.Message); } }
Under Windows (it works well under MacOs) You can have problem with a codePage exception. Add the dlls I18N et I18N.West to your assets. Hope it can help