The sample demonstrates the basics of reading and writing text and binary files using the StorageFolder and StorageFile classes. When the app runs, it displays a menu of individual tasks that you can test.

This sample shows you how to use the following APIs:

Group

API methods

Location of important folders

Package.Current.InstalledLocation

ApplicationData.Current.LocalFolder

StorageFolder methods

CreateFileAsync

CreateFolderAsync

DeleteAsync

GetFilesAsync

GetFolderAsync

GetFoldersAsync

StorageFile methods

DeleteAsync

GetFileAsync

OpenAsync

OpenReadAsync

OpenStreamForWriteAsync

DataReader methods

LoadAsync

ReadString

DataWriter methods

WriteString

StoreAsync

Stream methods

CopyToAsync

This sample also demonstrates the following features and tasks:

  • Recursive navigation of directory free.

  • Passing data from one page to another page without using the query string in the page URI.

  • Persisting app-level data when the app is deactivated.

  • Capturing the output of the PhotoChooserTask.

  • Capturing the output of the CameraCaptureTask.

  • Including all UI strings as localizable resources.

For more info about file handling in Windows Phone 8, see Quickstart: Working with files and folders in Windows Phone 8.

Build the sample

  1. Start Visual Studio Express 2012 for Windows Phone and select File > Open > Project/Solution.

  2. Go to the directory in which you unzipped the sample. Double-click the Visual Studio Express 2012 for Windows Phone solution (.sln) file.

  3. Use Build > Rebuild Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

How to work with photos in the samples

To test the Copy existing photo to local folder task in the Emulator, you first have to visit the Photos Hub one time to populate it with some sample images. By default there are no sample photos.

To test the Save new photo to local folder function in the Emulator, press F7 in the camera view to take a picture, and then click accept. The picture is simply a gray rectangle.