Download
When calling theDocumentAgent.CreateTempFile method, the temporary file name and the document stream for the original document are passed into the method.
IDocumentAgent.GetDocumentStream is used to download the document contents from the server. The temporary filename is used for storing the contents locally and, once the file is created, you have to explicitly close, and dispose of the steam to eliminate concurrent access issues. At this point, you may modify the document.
Upload
Assuming the modifications are done, the next step is to upload the modified document to the document archive folder. This is achieved by setting the file stream of the temporary modified file as the document stream for the original document entity. Using aFileStream instance, and passing in the full path to the local file, the file open mode, and the file access details, you prepare the document for upload.
The IDocumentAgent.SetDocumentStream method is used to do perform the actual upload. SetDocumentStream() requires 3 parameters:
- The original document entity
- The stream for the temporary local file
- The Boolean value specifying whether the stream will overwrite an existing file with the same name stored in the document archive