Click or drag to resize
Check out to file system

This example shows how you can check out a document to file system. The check out operation downloads the first section of the document while also marking it as checked out. The downloaded file downloaded file has the document address encoded in the file name. The check in operation takes a file with name that has document address encoded which is the replacement of the first section of the document. After the successful upload the document checkout mark is deleted.

Check in/out file name format
  1. The file name starts with the document id encoded as decimal number.

  2. The next character is a plus sign (+).

  3. The next part is the id of the file cabinet. It is formatted as string which contains only characters a-f and digits and dashes ('-'). More precisely, it is a GUID using the following pattern: 00000000-0000-0000-0000-000000000000.

  4. The next character is a plus sign (+).

  5. Optionally the document name can follow. The document name must consist only of the following characters. Any character not matching these rules is not allowed and must be replaced with an underscore (_).

  6. Each character of the Unicode class letter is allowed.

  7. Any digit (0-9) is allowed.

  8. The white space character with the code 32 is allowed. Also the underscore (_) is allowed.

  9. The file name ends with the file extension, beginning with a period.

  10. The file name length, including the extension, does not exceed 80 characters.

Check out file to file system and check it back in.

Check out file to file system and check it back in.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;
using DocuWare.Services.Http;

namespace DocuWare.PlatformClientExamples

    static partial class ExamplesAsync
        public async static Task<Document> CheckOutCheckInAsync(ServiceConnection connection, string fileCabinetId, int docId)
            var fileInfo = await CheckOutToFileSystem(connection, fileCabinetId, docId);

            // Do something with the file, e.g. open it in external editor and wait until the editing operation is finished.
            await Task.Delay(2000);

            var checkInData = new CheckInActionParameters() { Comments = "comments...", DocumentVersion = new DocumentVersion() { Major = 1, Minor = 1 } };
            return await connection.EasyCheckInFromFileSystemAsync(fileInfo, checkInData);

        public async static Task<FileInfo> CheckOutToFileSystem(ServiceConnection connection, string fileCabinetId, int docId)
            using (EasyCheckoutResult result = await connection.EasyCheckOutToFileSystemAsync(fileCabinetId, docId))
                string tempPath = Path.Combine(Path.GetTempPath(), result.EncodedFileName);

                using (var file = System.IO.File.Create(tempPath))
                using (var stream = result.Response.Content)
                    await stream.CopyToAsync(file);

                return new FileInfo(tempPath);