thug sodier
thug sodier

Reputation: 13

How do i save json Object to Assets folder using LocalStorage

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

Answers (1)

Tom Droste
Tom Droste

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

Related Questions