Microsoft KB Archive/312174

= How to use PKMCDO to create folders in the documents section of a SharePoint Portal Server workspace in Visual C# =

Article ID: 312174

Article Last Modified on 12/11/2006

-

APPLIES TO


 * Microsoft Visual C# 2005
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft SharePoint Portal Server 2001

-



This article was previously published under Q312174





SUMMARY
This article describes how to use Microsoft Publishing and Knowledge Management Collaboration Data Objects (PKMCDO) for the Microsoft Web Storage System Library to create folders in the documents section of a Microsoft SharePoint Portal Server workspace from Microsoft Visual C#.



MORE INFORMATION
To use PKMCDO to create folders in the documents section of a workspace from Visual C#, follow these steps:  Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and then click Project. In the Visual C# Projects types list, click Console Application.

In Microsoft Visual C#. NET, Class1.cs is created by default. In Microsoft Visual C# 2005, Program.cs is created by default.

Note In Visual Studio 2005, click Console Application in the Visual C# list. Add a reference to the Microsoft PKMCDO for Microsoft Web Storage System Library. To do so, follow these steps:  On the Project menu, click Add Reference. Click the COM tab, locate Microsoft PKMCDO for Microsoft Web Storage System Library, and then click Select.

Note In Visual Studio 2005, you do not have to click Select.</li> In the Add References dialog box, click OK.</li> If you are prompted to generate wrappers for the libraries that you selected, click Yes.</li></ol> </li> Repeat step 4 to add a reference to the Microsoft ActiveX Data Objects 2.6 Library.</li>  In the code window, replace the code in Main method with the following: //TODO: Change the following sHref to reflect the folder that you want to create String sHref = &quot;http://ncsps/wsName/Documents/foldername&quot;; //TODO: Change the following array to reflect the Content classes that you want as expected content classes Object[] arrExpectedContentClasses = {&quot;urn:content-classes:basedocument&quot;, &quot;urn:content-classes:CC1&quot;, &quot;urn:content-classes:knowledgefolder&quot;, &quot;urn:content-classes:smartfolder&quot;};

PKMCDO.KnowledgeFolder oFolder = new PKMCDO.KnowledgeFolder; oFolder.Description = &quot;Test Description&quot;; oFolder.ContentClass = &quot;urn:content-classes:knowledgefolder&quot;; oFolder.DataSource.SaveTo(sHref,       null,         PKMCDO.ConnectModeEnum.adModeReadWrite,        PKMCDO.RecordCreateOptionsEnum.adCreateCollection,        PKMCDO.RecordOpenOptionsEnum.adOpenSource,                &quot;&quot;,&quot;&quot;); // For smartfolders, the expected content classes are not set // correctly at create time; they will be updated after saveto is called

oFolder.ExpectedContentClass = arrExpectedContentClasses; oFolder.DataSource.Save;

</li> Search for TODO in the code, and then modify the code for your environment.</li> Press F5 to build and to run the program.</li> Load the SharePoint Portal Server folder in Microsoft Internet Explorer, and then make sure that the folder was created.</li></ol>

<div class="references_section">