Hi there,
I’m currently stuck with one big problem. I’m downloading a zip file from the server and while writing the zip file in persistent data path, my app crash with no log, no error, no exception. I searched everywhere but didn’t find anything.
This is the code writing zip file :
Debug.Log("Start downloading ALL ZIP");
downloadAllZip = new WWW(NetworkManager.Instance.ServerAddress + "/ws/file/index/");
LoadingScreen.Instance.SetText ("Loading resources from internet, This may take several minutes... ");
while (!downloadAllZip.isDone) {
// Debug.Log ("Progress " + downloadAllZip.progress);
yield return new WaitForEndOfFrame();
}
Debug.Log ("Zip downloaded");
try {
if(!string.IsNullOrEmpty(downloadAllZip.error)) {
Debug.LogError("Error in download all zip : " + downloadAllZip.error);
}
else
{
Debug.Log("End of download ALL ZIP");
LoadingScreen.Instance.SetText ("Saving resources ... ");
ResourcesPath = ResourcesPath.Replace("\\","/");
Debug.Log ("Writing zip at : "+ResourcesPath + " - size : " + (downloadAllZip.size / 1000000f).ToString("F2") + "Mb");
DataManager.WriteFile(ResourcesPath, downloadAllZip.bytes);
// System.IO.File.WriteAllBytes(ResourcesPath, downloadAllZip.bytes);
Debug.Log("Zip saved");
The last display is :
“Writing zip at : /storage/sdcard0/Android/data/com.allucyne.colmarafdts/files/Data/Resources/resources.zip - size : 205.26Mb”
And after it crashes.
Note that I have Unity 4.6.8f1, and the DataManager is used in other projects and is working. There is error management in DataManager, and no error is fired.
Just to show you the WriteFile method :
/// <summary>
/// Writes a file with the datas
/// </summary>
/// <param name="_filePath">file path.</param>
/// <param name="_data">data to write</param>
public static void WriteFile(string _filePath, byte[] _data)
{
try
{
_filePath = ConvertPath (_filePath);
if(_data != null)
{
// Debug.Log("Write file : " + _filePath + " - size : " + (_data.LongLength / 1000f).ToString("F3") + "Kb");
try
{
#if UNITY_WP8 || NETFX_CORE
Debug.Log("Write file with unityengine windows method");
UnityEngine.Windows.File.WriteAllBytes (_filePath, _data);
#else
Debug.Log("Write file with mscorlib method");
File.WriteAllBytes(_filePath, _data);
#endif
Debug.Log("Write successful");
}
catch(Exception e)
{
Debug.LogError("Error writing file : " + _filePath + ", error : " + e.Message);
}
}
else
{
Debug.LogError("Error, data is null");
}
}
catch(Exception ex)
{
Debug.LogError("[DataManager] Error while writing file " + _filePath + " : " + ex.Message);
}
}
I’m stuck since a lot of weeks with this…I don’t know if the file is too big or anything else. I’m using Ionic.Zip for the ZipFile but here i’m just writing bytes, so Zip has nothing to do with the problem I think.
Thanks a lot.