title: How to get root directory of project in asp.net core. Directory.GetCurrentDirectory() doesn't seem to work correctly on a mac
body: <p>My project has a folder structure to the tune of:</p>
  
  <ul>
  <li>Project,</li>
  <li>Project/data</li>
  <li>Project/Engine</li>
  <li>Project/Server</li>
  <li>project/front-end</li>
  </ul>
  
  <p>In the server (running in the Project/Server folder) I refer to the folder like this:</p>
  
  <pre><code>var rootFolder = Directory.GetCurrentDirectory();
  rootFolder = rootFolder.Substring(0,
              rootFolder.IndexOf(@"\Project\", StringComparison.Ordinal) + @"\Project\".Length);
  PathToData = Path.GetFullPath(Path.Combine(rootFolder, "Data"));
  
  var Parser = Parser();
  var d = new FileStream(Path.Combine(PathToData, $"{dataFileName}.txt"), FileMode.Open);
  var fs = new StreamReader(d, Encoding.UTF8);
  </code></pre>
  
  <p>On my windows machine this code works fine since <code>Directory.GetCurrentDirectory()</code> reffered to the current folder, and doing</p>
  
  <pre><code>rootFolder.Substring(0, rootFolder.IndexOf(@"\Project\", StringComparison.Ordinal) + @"\Project\".Length); 
  </code></pre>
  
  <p>gets me the root folder of the project (not the bin or debug folders). 
  But when I ran it on a mac it got "<code>Directory.GetCurrentDirectory()</code>" sent me to /usr//[something else]. It didn't refer to the folder where my project lies.</p>
  
  <p>What is the correct way to find relative paths in my project? Where should I store the data folder in a way that it is easily accessible to all the sub projects in the solution - specifically to the kestrel server project? I prefer to not have to store it in the wwwroot folder because the data folder is maintained by a different member in the team, and I just want to access the latest version. What are my options?</p>