![](/img/trans.png)
[英]How can I access the address book in Xamarin.forms (for android and iOS)?
[英]How can I access the filepath to Resources (iOS) folder in Xamarin.Forms?
我的應用程序的iOS部分的Resources文件夾中有一個.sqlite文件。 現在在AppDelegate.cs中,我有:
string dbname = "test.sqlite";
string folderPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Resources), "..", "Library");
string fullPath = Path.Combine(folderPath, dbname);
我的問題是,當我使用sqlite-net-pcl庫加載sqlite文件時,它顯示一個空數據庫,盡管sqlite文件中有超過10,000行。 我認為問題是我鏈接到錯誤的內容。
sqlite文件再次位於Resources文件夾中。 如何訪問其文件路徑?
哈利路亞我想通了!
NSBundle.MainBundle.PathForResource("test", "sqlite");
返回資源的文件路徑(至少它在我的模擬器上有效)。 我將在實際設備上對此進行測試,並將結果發布,但現在它可以正常工作了。 本質上,以上命令搜索指定的資源,第一個字符串為名稱,第二個字符串為擴展名,在本例中為sqlite。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.