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. - In the Add References dialog box, click OK.
- If you are prompted to generate wrappers for the libraries that you selected, click Yes.
- Repeat step 4 to add a reference to the Microsoft ActiveX Data Objects 2.6 Library.
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 = "http://ncsps/wsName/Documents/foldername"; //TODO: Change the following array to reflect the Content classes that you want as expected content classes Object[] arrExpectedContentClasses = {"urn:content-classes:basedocument", "urn:content-classes:CC1", "urn:content-classes:knowledgefolder", "urn:content-classes:smartfolder"}; PKMCDO.KnowledgeFolder oFolder = new PKMCDO.KnowledgeFolder(); oFolder.Description = "Test Description"; oFolder.ContentClass = "urn:content-classes:knowledgefolder"; oFolder.DataSource.SaveTo(sHref , null, PKMCDO.ConnectModeEnum.adModeReadWrite, PKMCDO.RecordCreateOptionsEnum.adCreateCollection, PKMCDO.RecordOpenOptionsEnum.adOpenSource, "",""); // 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();
- Search for TODO in the code, and then modify the code for your environment.
- Press F5 to build and to run the program.
- Load the SharePoint Portal Server folder in Microsoft Internet Explorer, and then make sure that the folder was created.
REFERENCES
For more information, visit the following MSDN Web site:
Additional query words: Microsoft PKMCDO, Microsoft Web Storage System Library, create, folder, documents section
Keywords: kbhowtomaster kbmsg KB312174