Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 312174 - Last Review: December 11, 2006 - Revision: 2.6
How to use PKMCDO to create folders in the documents section of a SharePoint Portal Server workspace in Visual C#
This article was previously published under Q312174
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# .
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.
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
| kbhowtomaster kbmsg KB312174 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate