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

Is File.ReadAllLines path supposed to continue from the project folder?

Discussion in 'Linux' started by LukaKotar, Oct 16, 2015.

  1. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    394
    When I do File.ReadAllLines("some/path"), I get a message in the console saying it can't find "/home/*user*/Actual/Project/Path/some/path". This makes it impossible to read a file outside of the project. Is this an issue with the Linux editor, or is it by design?
     
  2. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    This is the normal behavior.
     
    LukaKotar likes this.
  3. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    If you want the home folder of the current user you can use the SpecialFolder enumeration like this:

    string homeFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);

    On Linux this gives the user's home folder. It probably gives the "Documents" folder on Windows and possibly something else on OSX, so keep that in mind. You may want to use compiler flags for each system to get the different paths.

    Hope this helps :)
     
    LukaKotar likes this.
  4. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    394
    Thanks, that worked!