我正在尝试使用ashx文件中的Server.MapPath连接到SQLite数据库。它在localhost上运行良好但是当我从webserver运行它时它不会连接到数据库。我不知道是因为MapPath?我需要改变别的吗?
private static readonly string APP_PATH = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
private static readonly string DB_PATH = Path.Combine(APP_PATH, "data");
答案 0 :(得分:0)
使用BaseDirectory解决了这个问题:
private static readonly string DB_PATH = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "data");