[英]AppDomain.CurrentDomain.BaseDirectory changes to wrong directory
[英]AppDomain.CurrentDomain.BaseDirectory changes according to the app's target platform
我將此路徑設置為應用程序根目錄的路徑。
直到我決定將System.Data.SQLite.dll
庫和應用程序更改為32位(而不是64位)(最初更改為32bit,因為我下載了sqlite lib的64位版本)后,它才能正常工作。
private string fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testdb.db");
問題是在啟動時出現錯誤,表明access to "C:/Program Files (x86)/Microsoft Visual Studio 11.0/IDE/test.db" is denied
,這意味着AppDomain.CurrentDomain.BaseDirectory
會以某種方式引用到該目錄,而不是應用程序的根目錄。
這可能是什么原因?
更新 :顯然,將應用程序平台目標更改為x64,並使用64b版本的SQLite可以解決此問題...
我認為這是因為您通過按F5在Visual Studio托管的調試模式下啟動了應用程序!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.