Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Directory not found when trying to write to persistentDataPath

Discussion in 'Scripting' started by kyrios592_unity, Dec 11, 2019.

  1. kyrios592_unity

    kyrios592_unity

    Joined:
    Mar 19, 2018
    Posts:
    3
    On unity 2019 I'm trying to write to the persistent data path on android, but it throws a DirectoryNotFound exception, here is the code I am using:

    Code (CSharp):
    1.  
    2. var filePath = Path.Combine(Application.persistentDataPath, fileName);
    3. File.WriteAllBytes(filePath, fileData);
    4.  
    Any idea on what I am missing/doing wrong ?
     
  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    So what is the filename? Does it define a subfolder, and if so, does that subfolder exist
     
  3. kyrios592_unity

    kyrios592_unity

    Joined:
    Mar 19, 2018
    Posts:
    3
    it does not define a subfolder, it's just "xxxx.json", the error is:

    12/10 23:14:46.129 22215 22279 Error Unity: DirectoryNotFoundException: Could not find a part of the path "/jar:file:/data/app/com.Epitech.Globswar-klv4qx1S_vWpPoYicgkgKA==/base.apk!/assets/StreamingAssets/file.json".
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,653
    The path you pasted is Application.streamingAssetsPath, not persistentDataPath.
     
  5. kyrios592_unity

    kyrios592_unity

    Joined:
    Mar 19, 2018
    Posts:
    3
    Yes, I pasted the wrong one, my bad, I'm not home right now, so I can't get it