c# - Unity3D UnauthorizedAccessException: Access to the path is denied -
i have anayltics in unity3d game , realised android devices throw unauthorizedaccessexception when trying create folder on device.
have @ code throws exception:
static void savetocache(entry entry, byte[] bytes) {     if (entry.file != null) {         string path = path.getdirectoryname(entry.file);         try {             if (!directory.exists(path)) directory.createdirectory(path);             file.writeallbytes(entry.file, bytes);                   } catch (exception ex) {             analytics.logexception(ex, "couldn't save cache: " + path);         }     } } the code looks me, perhaps i'm missing something... not throw on test devices - have stack trace analytics.
more relevant code how build path:
static readonly char directoryseparator = path.directoryseparatorchar;      static string bundlefile(string id, string languagecode) {     stringbuilder sb = new stringbuilder();     sb.append(bundlepath());     sb.append(id);     sb.append("_");     sb.append(languagecode.tolower());     sb.append(".json");     return sb.tostring(); }  static string bundlepath() {     stringbuilder sb = new stringbuilder();     sb.append(application.persistentdatapath);     sb.append(directoryseparator);     sb.append("bundles");     sb.append(directoryseparator);     return sb.tostring(); } please tell me if out there has similar issues. can't rely on application.persistentdatapath ? there better way build path cache files?
i solved problem writing toolkit handling persistent data paths on android. checks write access , uses fallback if disk space running out.
Comments
Post a Comment