Provides methods for accessing the storage functionality of a portable device that supports WPD.
Removable storage devices include:
- USB mass storage flash drives and cameras
- Media Transfer Protocol (MTP) music players, phones, and cameras
- Picture Transfer Protocol (PTP) cameras
Syntax
var storageDevice = Windows.Devices.Portable.StorageDevice;
Attributes
- MarshalingBehaviorAttribute(Agile)
- StaticAttribute(Windows.Devices.Portable.IStorageDeviceStatics, NTDDI_WIN8)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
Members
The StorageDevice class has these types of members:
Methods
The StorageDevice class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| FromId | Gets a StorageFolder object from a DeviceInformation Id for a removable storage device. |
| GetDeviceSelector | An Advanced Query Syntax (AQS) string for identifying removable storage devices. This string is passed to the FindAllAsync or CreateWatcher method. |
Remarks
To access the device services, you must declare the device service in the capabilities section of the app manifest file. For a list of the GUIDs representing the device services, see Windows.Devices.Portable.
Examples
The following example shows how to get an interface ID using GetDeviceSelector and the Windows.Devices.Enumeration API. It also shows how to pass it to FromId to get a StorageFolder for a removable storage device.
Enum = Windows.Devices.Enumeration;
// Enumerate removable storage devices.
// The success callback selects the removable storage to use.
function pickStorageToGetImageFrom() {
Enum.DeviceInformation.findAllAsync(
Windows.Devices.Portable.StorageDevice.getDeviceSelector(),
null).then(
successCallback,
errorCallback);
}
// Handler that's called when removable storages are found.
// storageDevices: A collection of type
// Windows.Devices.Enumeration.DeviceInformationCollection.
// This example just takes the first storage found in the list.
function successCallback(storageDevices) {
var removableStorage = null;
if (storageDevices.length) {
try {
// Get the StorageFoler from the id for the first removable storage device
removableStorage = Windows.Devices.Portable.StorageDevice.fromId(
storageDevices.getAt(0).id);
// document.getElementById("output").innerHTML = storageDevices.getAt(0).name;
} catch (e) {
document.getElementById("output").innerHTML =
"Error: " + e.message;
}
if (removableStorage != null) {
getImageFiles(removableStorage);
}
} else {
document.getElementById("output").innerHTML =
"No removable storage devices were found.";
}
}
The following examples show the syntax of a call to FromId in C# and C++.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
|
Capabilities |
|
See also
Build date: 12/4/2012