Search Unity

  1. Going to #UniteBerlin? Bring a buddy & get 25% off the 2nd ticket! More info here.
    Dismiss Notice
  2. Famed game designer and creator of The Sims, SimCIty, and Spore is looking for a 3D artist to join their team. Join the challenge.
    Dismiss Notice
  3. Unity 2017.4 has arrived! Read about it here.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. We've opened a new World Building sub-forum to faciltate all your world building discussions! Drop in and ask any ProBuilder, ProGrids, or PolyBrush questions.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

DirectoryNotFoundException for StreamingAssets on Mac

Discussion in 'OSX' started by Vedrit, Jun 23, 2017.

  1. Vedrit

    Vedrit

    Joined:
    Feb 8, 2013
    Posts:
    489
    Hi all,
    I have a client that, when they try to run my game, they get
    Code (csharp):
    1.  
    2. DirectoryNotFoundException: Could not find a part of the path "/private/var/folders/5p/bq_l_2w95r9fwc9ms971tflw0000gn/T/AppTranslocation/FC5A4B32-E769-4053-B81F-D5ACBE4D1C2C/d/Mac Client.app/Contents/StreamingAssets/profanityList.txt".
    3.   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x001be] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs:292
    4.   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
    5.   at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    6.   at System.IO.File.OpenRead (System.String path) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:363
    7.   at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x00077] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/StreamReader.cs:167
    8.   at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding) [0x00000] in <filename unknown>:0
    9.   at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string,System.Text.Encoding)
    10.   at System.IO.File.ReadAllText (System.String path, System.Text.Encoding encoding) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:587
    11.   at System.IO.File.ReadAllText (System.String path) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:582
    12.   at Chat.Start () [0x00010] in D:\TFW\The False World\Assets\Scripts\UI scripts\Chat.cs:75
    13.  
    14. (Filename: /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/FileStream.cs Line: 292)
    I've tested on Windows and Ubuntu, and neither encounter this error.
    I'm accessing the StreamingAssets folder by using the following
    Code (csharp):
    1.  
    2.         string file = File.ReadAllText(Application.dataPath + "/StreamingAssets/profanityList.txt");
    3.  
    Which, according to the docs, should be valid for Mac OS.
    Anyone have any suggestions on what might be causing the issue?
    Thanks!
     
  2. pepipe

    pepipe

    Joined:
    Jun 2, 2014
    Posts:
    3
    This is a kinda old topic but for someone (like me) that encounter this error again.

    I was building a old game done in Unity 4.x for Mac (I'm using 4.7.1) and I needed to read something from StreamingAssets. It worked fine in Windows Unity Editor and in Mac Unity Editor.

    Did the builds and then in Mac the app crashed when assessing the StreamingAssets. Don't know why but the Application.dataPath for the Mac Builds is not correct. In my case it was giving the following address:
    Code (CSharp):
    1. /Users/<my_user>/<path to .app>/Contents/
    but the StreamingAssets folders in my .app is inside one more folder called "Data". So for the Mac Build (notice that in Editor it will be ok) I needed to add that extra "/Data/" manually.
     
    JoeStrout likes this.