Query21
Query21

Reputation: 200

How do we modify assets of the app package in runtime for Windows store apps

I can get a handle to my app package using Windows.ApplicationModel.Package.current.installedLocation property. Please can you tell me if its possible to replace files in the package with newer ones during runtime. please provide snippets if possible.

Upvotes: 0

Views: 84

Answers (2)

Your package location is read-only by design. If you want to replace those contents at runtime, then take this strategy:

  • On first run, copy the file from the read-only page to a location in your local or temporary app data.
  • Always reference those contents from that app data location.
  • When you want to replace the file, just overwrite it in that app data location, and the rest of the code will work just the same.

Note that you can use ms-appx:/// and ms-appdata://local/ URIs to get to files via StorageFile.getFileFromApplicationUriAsync, rather than getting a StorageFolder first. This can simplify the code.

Upvotes: 1

Chubosaurus Software
Chubosaurus Software

Reputation: 8161

I'm pretty sure that directory is Read Only: See Access Denied Installed Location.

Why would you want to write to that directory in the first place? Why not go through the normal update process?

Upvotes: 0

Related Questions