MD Amanullah Hoque
MD Amanullah Hoque

Reputation: 161

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");

enter image description here

Here Is My Db File

enter image description here

Upvotes: 0

Views: 342

Answers (1)

Michael Hawker - MSFT
Michael Hawker - MSFT

Reputation: 1580

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

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

Build Action

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

Upvotes: 3

Related Questions