x First time here? Check out the FAQ

Creating a document

    Sample code to create a document and then publish it.

    Remember to add the cms.dll, businesslogic.dll and umbraco.dll to your project.

    Add references to the following namespaces at the top of your .cs file

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;

    Perform the creation

    // Create a document with the appropriate name, root node id, and document type alias.
    IContent doc = ApplicationContext.Services.ContentService.CreateContent("My new document", -1, "documentTypeAlias");

    // Set properties // See this article for setting properties of the document: http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties

    // Save and Publish ApplicationContext.Services.ContentService.SaveAndPublish(doc);