StorageDevice.GetDeviceSelector | getDeviceSelector method

Applies to Windows only

An Advanced Query Syntax (AQS) string for identifying removable storage devices. This string is passed to the FindAllAsync or CreateWatcher method.

Syntax


public static string GetDeviceSelector()

Parameters

This method has no parameters.

Return value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

An AQS string for identifying storage devices.

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 the DeviceInformation ID from the Devices.Enumeration API and pass it to FromId.


    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 a StorageFolder 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++.


var folder = StorageDevice.FromId(deviceInformationId); 



Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

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

Metadata

Windows.winmd

Capabilities

removableStorage

See also

Removable Storage Sample
StorageDevice

 

 

Show:
© 2014 Microsoft