IWMSRootDirectories.Count (C#)

The Count property retrieves the number of root directory paths in the IWMSRootDirectories collection.

int = IWMSRootDirectories.Count

Property Value

int containing the number of root directory paths in the collection.


This property is read-only.


using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

// Declare variables.
WMSServer                  Server;
IWMSRootDirectories        RootDirectories;

string                     strDir;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the IWMSRootDirectories object.
    RootDirectories = Server.RootDirectories;

    // Use the Count property as an iteration boundary
    // when accessing individual objects in the collection.
    for (int i = 0; i < RootDirectories.Count; i++)
        // Retrieve each root directory.
        strDir = RootDirectories[i];
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
catch (Exception e) {
    // TODO: Handle exceptions.


Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows ServerĀ 2003 family, Windows ServerĀ 2008 family.

See Also


IWMSRootDirectories Object (C#)