简体   繁体   中英

WinRT c# load a sqlite database from folder asset

I would like to load a prefab sqlite database from the folder Assets at the launch and copy it in the localstate of the application.

I try a lot of thing and every time I have a "Access denied" or "file not found".

Have you any idea how to do it ?

Regards

This is a weird quirk for Win 8 RT. I might guess that you have a special extension for your Sqlite db, like ".db" ... a workaround I have used is to use a ".txt" extension for the db in assets.

This works on my system without corrupting the file. I checked the db in Sqlite Database Browser.

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/db_in_assets.txt"));

await file.CopyAsync(ApplicationData.Current.LocalFolder, "db_in_local.db");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM