SaveOptions.TempFolder

SaveOptions TempFolder property. Specifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used.

SaveOptions.TempFolder property

Specifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used.

public string TempFolder { get; set; }

Exceptions

exceptioncondition
OutOfMemoryExceptionThrow if you are saving a very large document (thousands of pages) and/or processing many documents at the same time. The memory spike during saving can be significant enough to cause the exception.

Remarks

When Wordize saves a document, it needs to create temporary internal structures. By default, these internal structures are created in memory and the memory usage spikes for a short period while the document is being saved. When saving is complete, the memory is freed and reclaimed by the garbage collector.

Specifying a temporary folder using TempFolder will cause Wordize to keep the internal structures in temporary files instead of memory. It reduces the memory usage during saving, but will decrease the save performance.

The folder must exist and be writable, otherwise an exception will be thrown.

Wordize automatically deletes all temporary files when saving is complete.

Examples

Shows how to reduce Wordize memory footprint.

string tempDir = ArtifactsDir + "TempFiles";
// The specified temporary folder must exist in the local file system.
Directory.CreateDirectory(tempDir);

SaveOptions so = SaveOptions.CreateSaveOptions(SaveFormat.Docx);
so.MemoryOptimization = true;
so.TempFolder = tempDir;

LoadOptions lo = new LoadOptions();
lo.TempFolder = tempDir;

Converter.Create()
    .From(MyDir + "Simple.docx", lo)
    .To(ArtifactsDir + "SaveOptions.MemoryOptimization.docx", so)
    .Execute();

See Also