Search Unity

DirectoryNotFoundException for StreamingAssets on Mac

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

  1. Vedrit

    Vedrit

    Joined:
    Feb 8, 2013
    Posts:
    514
    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:
    10
    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.