title: Why AppDomain.CurrentDomain.BaseDirectory not contains "bin" in asp.net app?
body: <p>I have a web project like:</p>
  
  <pre><code>namespace Web
  {
      public partial class _Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              lbResult.Text = PathTest.GetBasePath();
          }
      }
  }
  </code></pre>
  
  <p>The method <code>PathTest.GetBasePath()</code> is defined in another Project like:</p>
  
  <pre><code>namespace TestProject
  {
      public class PathTest
      {
          public static string GetBasePath() 
          {
              return AppDomain.CurrentDomain.BaseDirectory;
          }
      }
  }
  </code></pre>
  
  <p>Why it's display <code>...\Web\</code> while the TestProject assembly is compiled into <code>bin</code> folder(in other words it should display <code>...\Web\bin</code> in my thought).</p>
  
  <p>Now I got a troublesome if I modified method into:</p>
  
  <pre><code>namespace TestProject
  {
      public class FileReader
      {
          private const string m_filePath = @"\File.config";
          public static string Read() 
          {
              FileStream fs = null;
              fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + m_filePath,FileMode.Open, FileAccess.Read);
              StreamReader reader = new StreamReader(fs);
              return reader.ReadToEnd();
          }
      }
  }
  </code></pre>
  
  <p>The <code>File.config</code> is created in TestProject. Now <code>AppDomain.CurrentDomain.BaseDirectory + m_filePath</code> will returen <code>..\Web\File.config</code> (actually the file was be copied into <code>..\Web\bin\File.config</code>), an exception will be thrown.</p>
  
  <p>You could say that I should modified <code>m_filePath</code> to <code>@"\bin\File.config"</code>. However If I use this method in a Console app in your suggest, <code>AppDomain.CurrentDomain.BaseDirectory + m_filePath</code> will return <code>..\Console\bin\Debug\bin\File.config</code> (actually the file was copyed into <code>.\Console\bin\Debug\File.config</code>), an exception will be thrown due to surplus <code>bin</code>.</p>
  
  <p>In other words, in web app, <code>AppDomain.CurrentDomain.BaseDirectory</code> is a different path where file be copyed into (lack of <code>/bin</code>), but in console app it's the same one path.<br>
  Any one can help me?</p>