ConnectorLib C++ 25.2
ConnectorLib C++ SDK Programming Guide

# Create Temporary Files

Your connector might need to create temporary files. The `task` objects have a `tempDirectory()` function that provides the path of the directory to use for storing temporary files.

The task object also provides a `getTempFilename` function to create a unique temporary file name:

           std::string tempFile = task.getTempFilename(tempDirectory, "TestDocument", ".doc");

This returns a unique path that can be used to store a temporary file. The method is passed three arguments, the temporary directory, a prefix, and an extension. The file name generated by the example begins with “TestDocument” and ends with the “.doc” extension. The middle of the file name is generated automatically to ensure the file name is unique.

Using this method has the following advantages:

- It always generates a unique file name – even in situations where different running tasks are using the same temporary directory.
- It always uses the temporary directory configured in the connector's configuration file.
- The file extension can be preserved.
- A human readable prefix can be used which can be useful when debugging a connector.

Copyright 2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ConnectorLib C++ 25.2

Topic Title: Create Temporary Files