Working with Application Folders

Custom applications can use an application folder on the home server to store all of the application's necessary files. If a home server has application folders, you can access information about the folders through the API for Windows Home Server and then use that information in your custom application for Windows Home Server.

ISVs typically install files in the Program Files folder. This is still an option with Windows Home Server, but the Program Files folder is located on the system partition which has a limited size. You can use application folders for storing large amounts of data. However, you should minimize the time these files are kept open to allow Drive Extender to migrate them. Application folders are not duplicated.

Application Folder Properties

An individual application folder is represented as a IApplicationFolder object, and it has read-only properties for the following attributes:

  • Name

  • Folder Duplication status

  • Path

Application Folder Example

Step 1: Create an instance of WHSInfoClass

As with most API objects for Windows Home Server, retrieving information about application folders begins by creating an instance of the WHSInfoClass, as follows:

WHSInfoClass pInfo = new WHSInfoClass();
Dim pInfo As New WHSInfoClass()

Step 2: Use a WHSInfoClass method to work with application folders

Scenario 1: Access information about a specific WHS application folder

To get a reference to an existing application folder, use the GetApplicationFolder method of the WHSInfoClass. The GetApplicationFolder method takes a System.Guid structure as the only parameter, and it returns a IApplicationFolder object that represents an existing application folder:

Guid myID = new Guid("61320935-2B2F-4b10-84DC-2DFA819F0A97");
IApplicationFolder pFolder = pInfo.GetApplicationFolder(myID);
Dim myID As New Guid("61320935-2B2F-4b10-84DC-2DFA819F0A97")
Dim pFolder As IApplicationFolder = pInfo.GetApplicationFolder(myID)

Scenario 2: Access information about all WHS application folders

To retrieve all of the application folders on home server, use the GetApplicationFolders method. The GetApplicationFolders method takes no parameters, and it returns an array of IApplicationFolder objects.

Array folders = pInfo.GetApplicationFolders();
Dim folders As Array = pInfo.GetApplicationFolders()

The GetApplicationFolders method returns an array of IApplicationFolder objects that you can then loop through to get information about a particular application folder:

foreach (IApplicationFolder pFolder in folders) 
{
  Console.WriteLine("Name: {0}", pFolder.Name);
  Console.WriteLine("Path: {0}", pFolder.Path);
}
Dim pFolder As IApplicationFolder
For Each pFolder In folders
    Console.WriteLine("Name: {0}" + pFolder.Name)
    Console.WriteLine("Path: {0}" + pFolder.Path)
Next pFolder

Scenario 3: Create a new WHS application folder

To create a new Windows Home Server managed application folder, use the CreateApplicationFolder method of the WHSInfoClass. The CreateApplicationFolder method takes a System.Guid object and a string as the input parameters, and it returns a IApplicationFolder object that represents a new application folder:

Guid myID = Guid.NewGuid();
// The string is a friendly name for the folder
string name = "My application folder";
IApplicationFolder pFolder = pInfo.CreateApplicationFolder(myID, name);
Dim myID As Guid = Guid.NewGuid()
' The string is a friendly name for the folder
Dim name As String = "My application folder"
Dim pFolder As IApplicationFolder = pInfo.CreateApplicationFolder(myID, name)

You can create a GUID by using any method that you choose, but the parameter for both the CreateApplicationFolder and GetApplicationFolder methods must be of type System.Guid.

For the CreateApplicationFolder example above, the GUID was created with the System.Guid NewGuid() static method. This method creates a new System.Guid object with a new GUID value.

See Also

Reference

IApplicationFolder
WHSInfoClass

Concepts

Extending Windows Home Server
Working with WHSInfoClass
Working with Client Computers
Working with Users
Working with Managed Volumes
Working with Hard Disks
Working with Notifications
Working with Backups

Other Resources

Working with Shared Folders