次の方法で共有


How to Create Folders

Applies To: System Center 2012 - Service Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Folders are logical containers that can contain other folders and folder items. A folder must always have a parent folder. If a workspace folder ID is used to create the folder, the folder will become a root folder for that workspace. Because workspaces are actually just folders, you can create a new workspace by parenting a folder to the ServiceManager.Console.RootFolder folder from the Microsoft.EnterpriseManagement.ServiceManager.UI.Console management pack.

To create a new folder

  1. Create an instance of the ManagementPackFolder class. Specify the management pack that will host the folder, the identifier of the folder, and whether it is to be public or private.

  2. Set the DisplayName and Description properties.

  3. Set the ParentFolder property to the folder that will be the parent of your new folder.

  4. Call the AcceptChanges method on the management pack that will host the folder.

Example

The following example creates a workspace folder named Packaging and then creates a child folder named Requests. The icon assigned to the workspace folder is provided by the management pack. The icon assigned to the child folder is provided by the Microsoft.EnterpriseManagement.ServiceManager.UI.Console management pack.

EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
ManagementPack mp = new ManagementPack("Folder\\RePackaging.Library.xml", mg);
ManagementPack consolemp = mg.ManagementPacks.GetManagementPack("Microsoft.EnterpriseManagement.ServiceManager.UI.Console", "31bf3856ad364e35", new Version(""));

ManagementPackFolder folderWorkspace = new ManagementPackFolder(mp, "Folder.Packaging", ManagementPackAccessibility.Public);
folderWorkspace.ParentFolder = consolemp.GetFolder("ServiceManager.Console.RootFolder");
folderWorkspace.Description = "Manage software repackaging throughout the packaging pipeline.";
folderWorkspace.DisplayName = "Packaging";

ManagementPackFolder folderRequests = new ManagementPackFolder(mp, "Folder.Packaging.Requests", ManagementPackAccessibility.Public);
folderRequests.ParentFolder = folderWorkspace;
folderRequests.Description = "Contains views of the repackaging pipeline.";
folderRequests.DisplayName = "Requests";

ManagementPackImageReference imageFolder = new ManagementPackImageReference(folderWorkspace, mp.GetImage("Resources.Images.Package_32"), mp);
imageFolder = new ManagementPackImageReference(folderRequests, consolemp.GetImage("Microsoft.EnterpriseManagement.ServiceManager.UI.Console.Image.Folder"), mp);

mp.AcceptChanges();

Compiling the Code

Namespaces

Microsoft.EnterpriseManagement

Microsoft.EnterpriseManagement.Configuration

Assemblies

Microsoft.EnterpriseManagement.Core

See Also

Tasks

How to Create Folder Items

Other Resources

Scenario: Working with the Console