Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# IDocumentManager.InsertNewDocument Method

Inserts a new document into the given parent document folder.

IDocument InsertNewDocument(
IDocumentFolder parentFolder,
IDocument documentProperties,
string checkInComment,
Stream inStream,
string language,
bool inheritSecurity
);

#### Parameters

parentFolder
  The folder into which to insert the new document. Cannot be `null`.
documentProperties
  An `IDocument` instance containing meta-data properties for the new document. This object may be obtained by calling `CreateNewDocument`. Cannot be `null`.
checkInComment
  A string containing a comment that will be inserted into the document history as the initial check-in comment for the document. Cannot be `null`.
inStream
  A `Stream` from which the contents of the new document will be read. Cannot be `null`.
language
  The document content language. This is the ISO 639-1 language code, i.e. `en` for english. Specifying a `null` language will set the language to that of the current user.
inheritSecurity
  If set to true this will override the security set on the `IDocument` object, and will instead use the same security as the parent folder.

#### Return Value

The newly created `IDocument` instance.

Note: The returned document will be a newly instantiated document and will not be equal to the `documentProperties` parameter.

#### Remarks

This method will need to be called to store a newly created document permanently.

If there is already a document or subfolder in the parent folder with the same name as the supplied document, then the name of the newly inserted document will be changed. For example, if a document is submitted with a name of `report.doc` and this name already exists it will be changed to `report_1.doc` (or `report_2.doc` if `report_1.doc` also already exists). The name of the returned `IDocument` can be checked to see if it differs from the name requested in the `document` parameter.

Note: To use any document upload/download functionality, including using this method, you must install WSE 2.0 (http://msdn.microsoft.com/webservices/building/wse/).

#### Exceptions

Exception Type | Condition
--- | ---
PermissionDeniedException | The user does not have permission to insert a document into the given folder.
CollaborationException | The method call resulted in an error.
SoapException | There is a communication problem during the execution of the remote method call.
InvalidOperationException | The parent folder has not yet been inserted, has already been removed, or the new document is not new.

#### See Also

IDocumentManager Interface | Plumtree.Remote.PRC.Collaboration.Document Namespace