Language: HTML | XAML

Accessing data and files (XAML)

Applies to Windows and Windows Phone

Access files, folders, and data from your app.

File access through file pickers

Get started:
Quickstart: Accessing files with file pickers
How to save files through file pickers

File pickers give users explicit control over which files and folders your app can access, and give you an easy way to let users specify the name or location of a file to save. Call the file picker to let your users choose the files and folders that they want your app to work with. (And when the user gives your app access to a folder through the file picker, your app also gets access to that folder and all of its subfolders.)

If your app works with individual files or small lists of files, like most apps, these file picker interactions may be all you need to access files and folders for your app. If you don't need additional file system access, you can minimize your app's capability declarations and potentially simplify the review process when you submit your app to the Store. See File access and permissions to learn more about default file system permissions and the file picker.

For example, in this screen shot an email app called the file picker so that the user could choose a picture from Pictures.

A screen capture of a file picker with one file in the Pictures library selected to be opened.

And in this screen shot the Reader app called the file picker so that the user could specify the file name and location of the file to save.

A screen shot of a file picker used to save a file to OneDrive.

Programmatic access to files

Get started:
Quickstart: Accessing files programmatically

If your app has permission to access files and folders in a particular location, you can enumerate and access all the files in that location. See File access and permissions to learn which locations your app has access to automatically, and learn about ways your app can gain access to additional locations.

Access to app files and data

Learn more:
Managing application data
Defining app resources
How to load file resources

All apps can store and manage app-specific files and data on the local file system or the cloud, including resource files in the app package.

Read or write file data

Get started:
Quickstart: Reading and writing a file

You can read and write data to a file directly or by using streams.

In this section

TopicDescription

Quickstart: Accessing files programmatically

Access files and folders that are in a location like a folder, library, device, or network location. You can also query the files and folders in a location by constructing file and folder queries.

Quickstart: Reading and writing files

Read and write a file using a StorageFile object.

Quickstart: Getting file properties

Gets properties - top-level, basic, and extended - for a file represented by a StorageFile object.

How to track recently used files and folders

Track files that your user accesses frequently by adding them to your app's most recently used list. The platform manages the MostRecentlyUsedList for you by sorting items based on when they were last accessed, and by removing the oldest item when the list's 25-item limit is reached. All apps have their own MostRecentlyUsedList.

Quickstart: Managing folders in the Music, Pictures, and Videos libraries

Add existing folders of music, pictures, or videos to the corresponding libraries. You can also remove folders from libraries, and get the list of folders in a library.

Quickstart: Accessing HomeGroup content

Access content stored in the user's HomeGroup folder, including pictures, music, and videos.

How to protect files with Selective Wipe

You can use selective wipe to identify protected files in your app that can be revoked when a user of your app is no longer authorized to your app data. This is a common scenario for businesses that allow employees to bring their own device to work. When the employee leaves the company, the company files on their personal device can be removed.

Quickstart: Determining availability of OneDrive files

Determine if a Microsoft OneDrive file is available using the StorageFile.IsAvailable property.

How to customize Visual Studio template data (XAML)

Data already appears in the pages of a Hub, Grid, Split and Pivot project. That's because these templates contain files, code, and XAML tags that make this possible. It's easier to modify these files to show your data than it is to start with a blank page and add it all from scratch.

Quickstart: Read data from a service

By using the Hub, Grid, or Split project template in Visual Studio, you can more effectively create an app that displays data from any service, database, or other data source. These templates share a data model that organizes information into Items and groups, and you can more easily add functionality to your app if you organize your data to follow that model.

Access media libraries in Windows Phone apps

Discover stored photos, music, and videos from Windows Phone apps by using the guidance in this topic.

Access the SD card in Windows Phone apps

Store and access non-essential data on the optional microSD card to expand the available storage on Windows Phone devices, especially on low-cost devices that have limited internal storage.

Working with File Pickers

This section includes Quickstart and How-to topics explaining and illustrating how to incorporate file pickers into your apps.

 

Related topics

File access sample
File picker sample

 

 

Show:
© 2014 Microsoft