DirectoryNotFoundException for StreamingAssets on Mac

Hi all,
I have a client that, when they try to run my game, they get

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".
  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 
  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
  at System.IO.File.OpenRead (System.String path) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:363 
  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 
  at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string,System.Text.Encoding)
  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 
  at System.IO.File.ReadAllText (System.String path) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:582 
  at Chat.Start () [0x00010] in D:\TFW\The False World\Assets\Scripts\UI scripts\Chat.cs:75 

(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

        string file = File.ReadAllText(Application.dataPath + "/StreamingAssets/profanityList.txt");

Which, according to the docs, should be valid for Mac OS.
Anyone have any suggestions on what might be causing the issue?
Thanks!

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:

/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.

1 Like