File Path Functions

Resolve a file path, retrieve the directory portion of a file name, or create a temporary file.

These functions are exported by the KS module.

FileCreateTemp

Filename := FileCreateTemp()

Creates an empty temporary file and returns its full path.

The file is created in the system temporary directory, exists on return and is not removed automatically. Delete it with FileDelete when it is no longer needed.

FileDirName

Directory := FileDirName(Filename)

Returns the full path to Filename without the file name or trailing directory separator.

FileFullPath

FullPath := FileFullPath(Filename)

Returns the full path to Filename.

Examples

#Import "Ks" { FileDirName, FileFullPath }
Full := FileFullPath("data\items.txt")
Parent := FileDirName(Full)

Writes to a temporary file and removes it afterwards.

#Import "Ks" { FileCreateTemp }
Temp := FileCreateTemp()
try
    FileAppend "scratch data", Temp
finally
    FileDelete Temp

SplitPath, SetWorkingDir