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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5.3 WP8.1 can't create Directory!

Discussion in 'Windows' started by vladrybak, Dec 10, 2015.

  1. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Hello,
    There is some kind of regression on windows phone in Unity 5.3. Now I can't create folder in persistent data path. This line of code
    Directory.CreateDirectory(Application.persistentDataPath + "/38");
    causes an exception
    IOException: Could not find any part of the path: D:/WPSystem/AppData/Local/Packages/6ec76e3e-d3d6-4990-9a2b-35465c4a7d5d_pzq3xp76mxafg/LocalState/38
    at System.IO.Directory.CreateDirectory(String path)
    at Tester.Start()
    at Tester.$Invoke0(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    (Filename: <Unknown> Line: 0)
    It was worked in Unity 5.2.3. Is there any workaround? Should i report a bug?
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,672
    Does parent folder 'D:/WPSystem/AppData/Local/Packages/6ec76e3e-d3d6-4990-9a2b-35465c4a7d5d_pzq3xp76mxafg/LocalState/' exist?
     
  3. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Directory.Exists(Application.persistentDataPath) returns true
     
  4. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Now I builded to windows store 8.1 and got the same exception...
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,507
    Try this for a workaround:

    Code (csharp):
    1. var path = Path.Combine(Application.persistentDataPath, "38").Replace('/', '\\');
    2. Directory.CreateDirectory(path);
    I'll fill a bug report on this - we'll try to get a fix into a patch release (case 752546).
     
  6. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Thank you, it should work, and i found another way
    UnityEngine.Windows.Directory.CreateDirectory(UnityEngine.Windows.Directory.localFolder + "/38") ;
     
  7. Darjamfar

    Darjamfar

    Joined:
    Jun 4, 2012
    Posts:
    63
    I had this problem with Directory.CreateDirectory in 5.3.1f1. I applied the patch 5.3.1p1 but it still doesn't work.

    I used the suggestion of Windows.Directory.CreateDirectory and this works.