title: Alternative to FileStream in C# .NET
body: <p>In an Visual Studio environment, Project A (ASP.NET) references Project B (C#) in my solution like this:</p>
  
  <pre><code>Solution
  ├─Project B
  │ ├─data.txt
  │ └─process.cs  (a class BB with static initialization new FileStream("data.txt"))
  └ Project A (referencces Project B)
    ├─bin
    │ └─data.txt (copied from project B each time project B changes)
    └─Controllers
      └─mycontroller.cs (references the class BB)
  </code></pre>
  
  <p>The problem is that when I run the application, the working directory  is <code>C:\Program Files (x86)\IIS Express\</code>, so that data.txt cannot be read from the compiled version of <code>process.cs</code> which is in <code>bin</code>.</p>
  
  <p>For the moment, to solve the problem, I manually copied <code>data.txt</code> to this folder, but this solution is not viable.
  Note that changes to B must be coherent with other projects depending on B, which are not all ASP.NET project.</p>
  
  <p><strong>What changes should I make so that <code>data.txt</code> is accessible from my project without relying on me to copy the <code>data.txt</code> file to the <code>IIS Express</code> directory?</strong></p>
  
  <p>I would like to port my program to Azure Online and I cannot rely on this method. Thank you for your help.</p>
  
  <p>Other linked answers:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/a/7340954/1287856">This answer</a> is ASP.NET - specific, I cannot add server.MapPath because the project does not know about it.</li>
  <li><a href="https://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path">This answer</a> references project paths, but does not give me an hint about how to modify them.</li>
  </ul>