Accessing data and files (HTML)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

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

How to perform rich queries on app local data

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.

Retrieve data from data sources

Learn more:

Working with data sources

Apps can use data sources to retrieve data from underlying sources, such as databases, files, or RSS feeds. A data source can manipulate the data and display it in controls such as ListView or FlipView.

In this section

Topic Description

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

Get properties 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: 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 Microsoft OneDrive files

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

How to customize Visual Studio template data

In the Hub/Pivot, Hub, Pivot, Grid, and Split templates, the code that obtains the data needed for the app is in the data.js file. This file represents a sample data source for the app.

How to use a custom file to pass OEM info

Develop an app that uses a custom file to pass info from the OEM to the app.

How to create a custom data source

Learn how to create a custom IListDataAdapter and IListDataSource.

Working with File Pickers

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

 

File access sample

File picker sample