Cheng Chen
Cheng Chen

Reputation: 43523

deployment of a windows 8 application

When I compile my app in visual studio 2012 RC, I can see a bin\ folder generated in the project source folder as expected, in which there is a foo.exe, looks like the entry of the app. When I start debugging the app, its icon is put on the start screen and I can find a new folder created at

C:\Users\someone\AppData\Local\Packages\xxxxx_xxxxxx

But I can't find foo.exe in this folder, even after I searched the whole disk. It seems the win8 application has a different installation/deployment mechanism than old windows programs. My questions are:

(1) how/where the win8 app is deployed/installed?

(2) I want to use \AppData\Local\Packages\xxxxx_xxxxxx\LocalState as a local data folder(which equals to ApplicationData.Current.LocalFolder in the code), but the whole folder is deleted when right click the start screen icon and press "uninstall", without any warning. Any better place to store local data? Or I need SQLite? For example, my app writes all crash messages in error.txt, obviously I can't use sqlite in this case, and if I put error.txt in LocalState folder, users may already uninstalled the app, before I go to him to see what's in error.txt. Another scenario is: a user want to uninstall the app, but keep his local data(files). Obviously ApplicationData.Current.LocalFolder is not a good choice.

Upvotes: 5

Views: 3167

Answers (2)

ZombieSheep
ZombieSheep

Reputation: 29963

1) The Windows 8 packages are deployed to c:\Program Files\windowsapps\, but by default you don't have ownership of that folder and so can't access it. That's largely irrelevant, though. You should never have access to this folder by design.

2) Again, deleting the local data folders for an app on uninstall is expected behaviour. Otherwise, if you deployed an app via the store and it started to misbehave and took up all of your available storage, there'd be no simple way for a user to delete that data. Your assertion that there is no warning is not true, however. The uninstall popup clearly says "This app and its related info will be removed from this PC"

In some instances, storing data in the roaming folder may be an option, but this folder is not intended ofr large amounts of data - it's there to hold application settings / config options to roam between devices. You could probably put your crash log in there during dev (if it is small enough), but there is no guarantee that it will be synced to the cloud before the app gets uninstalled. Your best bet would probably be to use the Live SDK to sync data to the cloud, but again, you have no guarantee that data will be written instantly to the cloud.

Upvotes: 4

LewisBenge
LewisBenge

Reputation: 2696

You should be using isolated storage for persisting data to the file system on a Windows 8 Metro app. You can find the location using the following:

Windows.Storage.ApplicationData.Current.LocalFolder.Path;

As the architecture of each platform changes you will never know for sure where you data will be stored, but this constant will ensure it works across all applications. This folder is also kept "secure" whilst the application is installed, and upgraded so you shouldn't loose data be using it.

An example of this using SQLLite-net can be found at the bottom of this page: http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx

Upvotes: 1

Related Questions