DllNotFoundException: MonoPosixHelper System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool,bool) System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen) System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode) (wrapper remoting-invoke-with-check) System.IO.Compression.GZipStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode) FileHelper.Zip (System.String tozipstr) (at Assets/Script/FileHelper.cs:88) SaveWindow+<InsulatorSave1>c__IteratorE.MoveNext () (at Assets/Script/GUI/SaveWindow.cs:269) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) SaveWindow:Window(Int32) (at Assets/Script/GUI/SaveWindow.cs:83) UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, GUISkin, Int32, Single, Single, GUIStyle)
请教,如题,如何在U3d中压缩字符串,我如下的方法在控制台程序中正常运行,压缩3mb的文件和字符串都可以,压缩解压正常运行,但是在U3d中就:如上错误,是运行到第7行报错,说找不到dll,难道U3d真的不是完整的System.dll???
1 if (!string.IsNullOrEmpty(toCompress)) 2 { 3 Debug.Log("得到的待解压到字符串是:"+toCompress); 4 byte[] inBuffer = Encoding.UTF8.GetBytes(toCompress); 5 using (MemoryStream compressedStream = new MemoryStream()) 6 { 7 using (GZipStream gzip = new GZipStream(compressedStream, CompressionMode.Compress,true)) 8 { 9 gzip.Write(inBuffer, 0, inBuffer.Length); 10 } 11 12 compressedStream.Position = 0; 13 14 // store the length of the uncompressed array (inBuffer) at the first 4 bytes in outBuffer 15 byte[] outBuffer = new byte[compressedStream.Length + 4]; 16 System.Buffer.BlockCopy(compressedStream.ToArray(), 0, outBuffer, 4, Convert.ToInt32(compressedStream.Length)); 17 System.Buffer.BlockCopy(BitConverter.GetBytes(inBuffer.Length), 0, outBuffer, 0, 4); 18 19 return Convert.ToBase64String(outBuffer); 20 } 21 } 22 else 23 { 24 return string.Empty; 25 }
http://answers.unity3d.com/questions/7710/how-do-i-fix-the-monoposixhelper-reference.html 官网找,这个和你的相似问题
U3D不是完整的mono吧,一些IO相关的特性不支持很正常。这儿有个压缩的例子,你可以参考一下:http://answers.unity3d.com/questions/17870/whats-the-best-way-to-implement-file-compression.html