Reputation: 13
I serialized a data from the net to Json and i want to save it to a path in the application folder "Assets" how do i do it with Local Storage? or is IsolatedStorage the right option to use?
string js = JsonConvert.SerializeObject(up, Formatting.Indented);
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile textFile = await localFolder.CreateFileAsync("upcoming.Json", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream textStream = await textFile.OpenAsync(FileAccessMode.ReadWrite))
{
using (DataWriter textWriter = new DataWriter(textStream))
{
textWriter.WriteString(js);
await textWriter.StoreAsync();
}
}
Upvotes: 0
Views: 715
Reputation: 1324
It isn't possible to write to the assets folder, but you can write to the LocalStorage, RoamingStorage (synced across devices) or TemporaryStorage. Those storages are only accessible for your apps.
Below is a link to a guide with sample to help you on your way. http://jamescroft.co.uk/blog/uwp/how-to-implement-local-storage-in-universal-windows-apps/
Upvotes: 1