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



The information in this article applies to:

  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)
  • 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:
  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.

REFERENCES

For more information, visit the following MSDN Web site:

Modification Type:MinorLast Reviewed:10/4/2006
Keywords:kbHOWTOmaster kbMsg KB312174 kbAudDeveloper