Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Application.persistentDataPath returning Empty String on some machines

Discussion in 'Scripting' started by sevensails, Feb 4, 2016.

  1. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Tested on Unity 5.3.1 and Unity 5.3.2p1

    I have 2 machines here. Application.persistentDataPath is returning an empty string on Editor (Debug) and Windows x86 executables on 1 of these machines.

    I sent a build for an beta tester and he faced the same problem.

    Is this a known bug? It's hard to send a bug report because it seems to be something machine related (both are Using Windows 10).

    Thanks
     
  2. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Tested on 5.3.2p2... The bug remains... is there something I can check?
     
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,222
    Have a look in the log file. Any errors?
     
  4. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    No... nothing strange on output_log.txt.

    I created a workaround by using this folder and it's working :

    Code (csharp):
    1.  
    2. System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
    3.  
    How does Unity gets the APPLOW folder?
     
  5. mpgholden

    mpgholden

    Joined:
    Aug 21, 2014
    Posts:
    38
    Our team encountered this too, and the System.Environment.GetFolderPath workaround also resolved it for us. On 5.3.1p4.

    Application.persistentDataPath appears to be inconsistent. I know it failed on at least 2 Windows 10 machines and worked on at least 3 others. Our logs would show an error when it attempted to create a file at the empty string path.
     
    sevensails likes this.
  6. GerrardAquilon

    GerrardAquilon

    Joined:
    Sep 11, 2014
    Posts:
    3
    I have the same issue on 5.3.3p2 version (and already with the 5.3.3f1 version).

    Application.persistentDataPath is returning an empty string in editor. It happens on every computer we got here. (all running under windows 10)
     
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,222
    Can you file a bug report with a sample project so we can take a look please.
     
  8. GerrardAquilon

    GerrardAquilon

    Joined:
    Sep 11, 2014
    Posts:
    3
    I don't really know what happened but it's working again now... Can't send you a bug report then ! Sorry.
     
  9. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    131
    For us this problem appears very randomly when testing Android in Genymotion. But we see rare cases of errors reported from some devices.
     
  10. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    282
    The carriage return ( \r ) character in the ProductName was breaking the line at end of the Path, so this is why Application.persistentDataPath was returning string.Empty.

    persistentdatapath-fix.png
     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,222
    Could you file a bug report, please? We could probably do something about this in the future.
     
    dragontriad likes this.
  12. whizzkid

    whizzkid

    Joined:
    Nov 2, 2016
    Posts:
    8
    It also fails if you have a trailing space in the productname :)
     
    dragontriad and arufolo like this.
  13. arufolo

    arufolo

    Joined:
    Mar 5, 2013
    Posts:
    8
    WOW thank you for this. We actually had a trailing space in the Company Name causing issues. I would have never though to check this had it not been for your comment.
     
    dragontriad likes this.