Contents

Method

CreateTempFile

ModuleFileSystem
LibraryCore
Action

Creates an empty file in the OS temporary files location, reserving a unique name, and returns its path.

In Windows system context the location is %TEMP% which resolves to C:\Windows\temp by default, and when running TIMS in user context (default) then %TEMP% resolves to C:\Users\<user>\AppData\Local\Temp.

In macOS and *nix OS the location is /tmp.

Parameters

(None)

Return values

FilePath (string): The full path of the file created.

Example
This writes some text to a temporary file and reads it, deleting the file when it is no longer needed.
@path = FileSystem.CreateTempFile();
FileContent.WriteText(FilePath : @path, Text : "Hello");
@text = FileSystem.GetFile(FilePath : @path);
FileSystem.DeleteFileByName(FilePath : @path); 
SELECT Content FROM @text;
Platforms
  • Windows
  • Linux
  • MacOS
  • Solaris Intel
  • Solaris Sparc
  • Android
Notes

The created file is not automatically deleted. As the example shows, an instruction using this method is responsible for deleting the file when it is no longer needed.

The method can be called multiple times in an instruction and each time a file with a unique path is created. However, once the file has been deleted its name is available for re-use.

The OS temporary files location on Windows OS should not be confused with the 1E Client TemporaryDirectory setting (available in v5.1 onwards) which is %windir%\Temp by default.