Search Unity

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

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

  1. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    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

    Unity Technologies

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

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    662
    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:
    378
    Thanks, that worked!