Share via


About the Storage Object

The Storage object is bound at runtime to represent a given legacy storage on a device. It provides access to all of the properties and content exposed by that storage.

WPD Automation defines a minimum set of properties for each Storage object. The properties can be accessed by their names; see the WpdProperty reference page for a list. The full set of properties for a Storage object depends on the storage it represents and how that storage is defined for a particular device.

The Storage object inherits the common object functionality included in the properties, methods, and events of the WPDObject. This means that a Storage object can create new Storage objects by using the CreateNewObject method, add objects to its collection of child objects (accessed through its Children property) by using the WPDObject.AddChild method, and can remove child objects from its collection by using the WPDObject.RemoveChild method.

A Storage object is retrieved by using a zero-based numeric index into Device.Storages, which is a storagesCollection object that contains all of the storages on the device. A Storage object can also be retrieved by a Persistent Unique ID (PUID), or by an Object identifier (ObjectID). For more information on retrieving the PUID or ObjectID for an object, see Enumerating Services and Storages.

The following code shows all three methods for retrieving a Storage object.

// Retrieve a storage object by index.
var storageObject = deviceObject.Storages[0];

// Get the PUID of a storage object by index,
// and then retrieve a storage object by PUID.
var storagePUID = deviceObject.Storages[0].ObjectPersistentUniqueId;
var storageObject = deviceObject.Storages[storagePUID];

// Get the ObjectID of a storage object by index,
// and then retrieve a storage object by ObjectID.
var storageObjectID = deviceObject.Storages[0].ObjectId;
var storageObject = deviceObject.Storages[storageObjectID];

About the WPD Automation Object Model

Device Object

Enumerating Services and Storages

Storage Object

storagesCollection Object

WPDObject