With Windows Home Server, shared content can be kept in managed shared folders on the home server. By using the API for Windows Home Server, you can write code that retrieves information about shared folders, which you can then use in your custom application.
Shared Folder Properties
An individual shared folder is represented as a IShareInfo object, and it has read-only properties for the following attributes:
-
Name
-
Text description
-
Folder Duplication status
-
Media Library Sharing status
-
Path
Shared Folder Example
Step 1: Create an instance of WHSInfoClass
As with most API objects for Windows Home Server, retrieving information about shared folders begins by creating an instance of the WHSInfoClass, as follows:
WHSInfoClass pInfo = new WHSInfoClass();
Dim pInfo As New WHSInfoClass()
Step 2: Call the GetShareInfo() method
The GetShareInfo method is the WHSInfoClass method that you use to get information about shared folders on the home server. It returns an array of IShareInfo objects that represent all shared folders on the network:
Array shares = pInfo.GetShareInfo();
Dim shares As Array = pInfo.GetShareInfo()
Step 3: Loop through the array
Because the GetShareInfo method returns only an array of IShareInfo objects, you need to loop through the entire array to get information about a particular shared folder:
foreach (IShareInfo pShare in shares)
{
Console.WriteLine("Name: " + pShare.Name);
Console.WriteLine("Description: " + pShare.Description);
Console.WriteLine("Share Duplicated: " + pShare.IsDuplicated);
Console.WriteLine("Media Library: " + pShare.MediaConnectEnabled);
Console.WriteLine("Path To Share: " + pShare.Path);
}
Dim pShare As IShareInfo
For Each pShare In shares
Console.WriteLine("Name: " + pShare.Name)
Console.WriteLine("Description: " + pShare.Description)
Console.WriteLine("Share Duplicated: " + pShare.IsDuplicated)
Console.WriteLine("Media Library: " + pShare.MediaConnectEnabled)
Console.WriteLine("Path To Share: " + pShare.Path)
Next pShare
You can use this same approach whenever you are working with shared folders through the API for Windows Home Server.
See Also