Hi Guys,
This is our code which extracts a .unity3d.compressed file to a unity3d file. It works in PC standalone and in the Editor in Android mode.
public static void UncompressFile(string pathOfFileToRead, string pathOfFileToCreate)
{
using (ZipFile zip1 = ZipFile.Read(pathOfFileToRead))
{
foreach (ZipEntry e in zip1)
{
e.Extract(pathOfFileToCreate, ExtractExistingFileAction.OverwriteSilently);
}
}
Debug.Log("Uncompressed successfully");
}
But when I build I get this on an Android device. I have set WriteAccess to External in the Build Settings.
I/Unity (19121): UnauthorizedAccessException: Access to the path '/storage/sdc
ard0/Android/data/com.Lightmare.InfinityWars/files/Android/Downloaded Cards/Stat
ic/IW2013/Aberion, the Fist of Dawn.unity3d' is denied.
I/Unity (19121): at System.IO.FileStream..ctor (System.String path, FileMode
mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous,
FileOptions options) [0x00000] in <filename unknown>:0
I/Unity (19121): at System.IO.FileStream..ctor (System.String path, FileMode
mode) [0x00000] in <filename unknown>:0
I/Unity (19121): at (wrapper remoting-invoke-with-check) System.IO.FileStrea
m:.ctor (string,System.IO.FileMode)
I/Unity (19121): at Ionic.Zip.ZipEntry.InternalExtract (System.String baseDi
r, System.IO.Stream outstream, System.String password) [0x00000] in <filename un
known>:0
I/Unity (19121): Rethrow as ZipException: Cannot extract
I/Unity (19121): at Ionic.Zip.ZipEntry.InternalExtract (System.String baseDi
r, System.IO.Stream outstream, System.String password) [0x00000] in <filename un
known>:0
I/Unity (19121): at Ionic.Zip.ZipEntry.Extract (System.String baseDirectory,
ExtractExistingFileAction
I have also checked and both the file and directory do exist. We are using Application.persistentDataPath. Any ideas what I can do to resolve this? Or even ideas why it might work on PC but not on the device?