相关疑难解决方法(0)

为什么AppDomain.CurrentDomain.BaseDirectory在asp.net应用程序中不包含"bin"?

我有一个像以下网站项目:

namespace Web
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lbResult.Text = PathTest.GetBasePath();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

该方法PathTest.GetBasePath()在另一个项目中定义,如:

namespace TestProject
{
    public class PathTest
    {
        public static string GetBasePath() 
        {
            return AppDomain.CurrentDomain.BaseDirectory;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么...\Web\在将TestProject程序集编译到bin文件夹时显示它(换句话说,它应该显示...\Web\bin在我的想法中).

如果我修改了方法,我现在遇到了麻烦:

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, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net .net-assembly

25
推荐指数
3
解决办法
5万
查看次数

标签 统计

.net-assembly ×1

asp.net ×1

c# ×1