Returns a filename guaranteed to exist and be unique.

Syntax

TempFilename = SRP_Path("GetTempFilename", Prefix, Path)

Parameters

ParameterDescription
PrefixThe text you want used at the front of the filename. Only the first 3 letters of this value will be used. (Optional)
PathThe directory where you want the unique filename to be made. If omitted, the user's temporary directory is used. (Optional)

Returns

A unique filename pointing to a file that exists and is empty.

Remarks

Added in 2.2.6

The GetTempFilename service creates an empty file with a unique name and returns the full path and filename to that file. The file name will not mean much to a human looking at it because it will consists of random numbers and letters, though you can supply a Prefix up to 3 characters long. By default, this file will be created in the current user's temporary directory, but you can supply your own path if you want to create a unique filename elsewhere, such as when creating logs.

Example

// Example 1: create a unique file in the temp directory and write to it
OSWrite "Hello, World!" to SRP_Path("GetTempFilename") then NULL

// Example 2: create a unique log file in a custom logging directory
LogFile = SRP_Path("GetTempFilename", "LOG", ".\Logs")

See Also

GetTempPath

  • No labels