Microsoft Knowledge Base Email Alertz

(312174) - Describes how to use PKMCDO for the Microsoft Web Storage System Library to create folders in the documents section of a SharePoint Portal Server workspace from Visual C# .NET. Includes a code sample that you can use to create the folders.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











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

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:
  1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. 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.
  4. Add a reference to the Microsoft PKMCDO for Microsoft Web Storage System Library. To do so, follow these steps:
    1. On the Project menu, click Add Reference.
    2. 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.
    3. In the Add References dialog box, click OK.
    4. If you are prompted to generate wrappers for the libraries that you selected, click Yes.
  5. Repeat step 4 to add a reference to the Microsoft ActiveX Data Objects 2.6 Library.
  6. 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(); 
    
    					
  7. Search for TODO in the code, and then modify the code for your environment.
  8. Press F5 to build and to run the program.
  9. 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
Keywords: 
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