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
Perform the creation
//Get the type you would like to use by its alias
//and the user who should be the creator of the document
DocumentType dt = DocumentType.GetByAlias("Textpage");
User author = User.GetUser(0);
//create a document with a name, a type, an umbraco user, and the ID of the document's parent page.
//To create a document at the root of umbraco, use the id -1
Document doc = Document.MakeNew("My new document", dt, author, 1018);
//after creating the document, prepare it for publishing
//Tell umbraco to publish the document
//umbraco.library.PublishSingleNode(doc.Id); - obsolete
See this article for setting properties of the document: our.umbraco.org/.../modifying-document-properties