简体   繁体   中英

C# UWP Copy database from installed location to local folder

I have a database on "ms-appx:///Assets/mydbfile.db" . I want to copy it to the local application folder when the application will start the first time. Database Contain a large number of data.

I try with this Code. but it gives me an exception.

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

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

在此处输入图片说明

Here Is My Db File

在此处输入图片说明

I tried with a text file and your code worked fine.

Do you have the Build Action in the file properties set to Content ?

建立行动

Where are you trying to run your code within your app?

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