4

I'm going through the Windows 8 tutorial on managing app lifecycle and state and the tutorial goes through the code for creating roaming appdata for my app which allows me to keep data for my app across sessions - so if I closed (fully close) my app, the next time I run it that data can be loaded back.

Where does Windows actually keep this in file? I cannot locate it in C:\users\username\appData\roaming

Arvin
  • 1,391
  • 4
  • 19
  • 33

1 Answers1

9

C:\Users\*user name*\AppData\Local\Packages\*Package Number*\RoamingState

It would be easier to simply debug your application and look at an instance of this to get the location:

Windows.Storage.ApplicationDataContainer roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder;

or more exactly:

var path = Windows.Storage.ApplicationData.Current.RoamingFolder.Path
N_A
  • 19,799
  • 4
  • 52
  • 98
  • Thanks - how do I find my package number? – Arvin Sep 10 '12 at 15:01
  • Debug into your application and look at the value returned by `Windows.Storage.ApplicationData.Current.RoamingFolder;` – N_A Sep 10 '12 at 15:02
  • I tried (using javascript): `var roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder; console.log(roamingFolder);` however it's not letting the program run as it calls the debugger straight away. I think maybe I'm misunderstanding what you mean by "Debug into my application"? – Arvin Sep 10 '12 at 15:04
  • Hard to tell why that is. Can't you just do the first line and set a breakpoint on it and view the value using the debugger? – N_A Sep 10 '12 at 15:07
  • ah, it's errorring out because current.roamingFolder is not capitalised. However all I get returned in the console is: `[object Windows.Storage.StorageFolder]` – Arvin Sep 10 '12 at 15:10
  • 1
    Look at the `Path` property. Like `Windows.Storage.ApplicationData.Current.RoamingFolder.Path` – N_A Sep 10 '12 at 15:11
  • Excellent: `C:\Users\Arvin\AppData\Local\Packages\1be986de-f138-4135-b427-8041dfef87e6_1em60301wsydt\RoamingState` Thank you very much – Arvin Sep 10 '12 at 15:12
  • But curiously that folder is empty? – Arvin Sep 10 '12 at 15:13
  • How did you populate it? Could you link the tutorial? – N_A Sep 10 '12 at 15:15
  • Tutorial: [link](http://msdn.microsoft.com/en-us/library/windows/apps/hh986966.aspx) The code is: `var appData = Windows.Storage.ApplicationData.current; var roamingSettings = appData.roamingSettings; roamingSettings.values["userName"] = nameInput.value;` – Arvin Sep 10 '12 at 15:16
  • 1
    That would be because you're not storing a file, you're storing a setting. Notice how to get the roaming folder we have to explicitly say we want a folder. Otherwise you're just sticking it in the settings object. I'm not sure where that is stored in the filesystem. – N_A Sep 10 '12 at 15:19
  • ah i see. well I guess the more important question is how would I go about deleting that setting without coding it? Let's say for some reason someone using my app has run into a bug that caused my app not to work and they want to reset the settings – Arvin Sep 10 '12 at 15:21
  • I'm going to guess it's located here: Windows.Storage.ApplicationData.Current.LocalFolder , but I can't really say since I'm on my win 7 computer. If you're trying to test and want to reset you can just do a clean/rebuild and you should wipe it out. – N_A Sep 10 '12 at 15:22
  • Ok, there is a "Settings" folder within my package directory. Deleting its contents has reset all of my app to default. Thanks for your help! – Arvin Sep 10 '12 at 15:24