Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StorageDevice class

Applies to Windows only

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


public ref class StorageDevice abstract sealed 

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

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.

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


StorageFolder^ folder = StorageDevice::FromId(deviceInformationId);

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

None supported

Namespace

Windows.Devices.Portable
Windows::Devices::Portable [C++]

Metadata

Windows.winmd

Capabilities

removableStorage

See also

Removable Storage Sample

 

 

Show:
© 2014 Microsoft