Building a Windows 8 Metro App, Part 3: Listing 2

The SaveAsync method in LocalStorage.

static async private Task SaveAsync()
    StorageFile sessionFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename,
    IRandomAccessStream sessionRandomAccess = await
    IOutputStream sessionOutputStream = sessionRandomAccess.GetOutputStreamAt(0);
    DataContractSerializer sessionSerializer = new
    DataContractSerializer(typeof(Dictionary<string, object>));
    sessionSerializer.WriteObject(sessionOutputStream.AsStream(), _data);
    await sessionOutputStream.FlushAsync();

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at

comments powered by Disqus


.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events