Chapter 6. Working with Files

When I was first putting together the structure of this book, I intentionally left out a section on working with files. Whenever a developer faces a new platform, one of the first things that he or she does after “Hello, world” is to try reading or writing files on disk. As a result, you tend to get a lot of community-generated content early on in a platform’s inception that comprises a million and one different rehashes on how to read and write files.

However, upon deeper reflection I decided to include this chapter, not necessarily to show you how to read or write files, but how to work with files within the restrictions imposed by WinRT and the Windows Store app UX. One aspect to this is sandboxing, which prevents abuse of the filesystem and its attendant data (a common activity of malware). Another aspect relates to how all the file access is done in WinRT, and so we have to deal with components that blend operations between WinRT and .NET.

In this chapter I’ll take you through the various ways in which we can drive the filesystem. If you look in the download package for this chapter, you’ll find some solutions/projects in addition to the StreetFoo ones that we have been working with thus far. Some of the examples we build will be “scratch” examples that don’t fit into this greater body of work.

So, let’s get going. First we’ll look at the file picker.

The File Picker

Sandboxed file access control in the world of Windows Store apps is generally limited ...

Get Programming Windows Store Apps with C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.