O'Reilly logo

Programming Windows Store Apps with C# by Iris Classon, Matthew Baxter-Reynolds

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required