About the childrenCollection Object
All Service and Storage objects contain a childrenCollection of child objects. Child objects can be retrieved in their entirety, read and enumerated directly, retrieved partially by a list of formats, added to, or removed from a childrenCollection.
The Children property of a Service or Storage object returns a childrenCollection that contains all of the children contained in the object, as shown in the following example.
var aChildrenCollection = storage.Children;
The childrenCollection can also be enumerated directly through the same property by using the childrenCollection.Count property and a zero-based numeric index, as in this example.
for (i=0; i < aChildrenCollection.Count; i++)
{
var aChild = aChildrenCollection[i];
// Do something with each child in the collection.
}
The GetChildrenByFormat method of a Service or Storage object returns a childrenCollection that contains only the children that are formatted with one of the data formats specified in a list. This makes it easy, for example, to retrieve a collection of all the WMA and MP3 ringtones contained in a service.
var aChildrenCollection = service.GetChildrenByFormat(["Wma", "Mp3"]);
Note
For more information and examples of using the GetChildrenByFormat method, and of retrieving and enumerating the objects in a childrenCollection, see Enumerating the Content of a Service or a Storage.
Child objects that are created through the CreateNewObject method of a Service or Storage object can be added to a childrenCollection by using the WPDObject.AddChild method. Child objects already in a childrenCollection can be removed by using the WPDObject.RemoveChild method. For more information, see Creating and Deleting Objects.
Related topics