DIR_GetTempFileName

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > File > DIR: functions working on directories >

DIR_GetTempFileName

 

Description

 

Creates a name for a temporary file.

If a unique file name is generated, an empty file is created and the handle to it is released; otherwise, only a file name is generated.

 

Syntax

 

s = DIR_GetTempFileName(sPath, sPrefix [, uUnique] )

 

Returns

 

String.

 

Parameters

 

Name

Type

Optional

Meaning

sPath

String

No

The directory path for the file name

sPrefix

String

No

The prefix string.
The function uses up to the first three characters of this string as the prefix of the file name.

uUnique

Number

Yes

An unsigned integer to be used in creating the temporary file name

 

If uUnique is zero, the function attempts to form a unique file name using the current system time. If the file already exists, the number is increased by one and the functions tests if this file already exists. This continues until a unique filename is found; the function creates a file by that name and closes it. Note that the function does not attempt to verify the uniqueness of the file name when uUnique is nonzero.

 

Remarks

 

GUIDTXT$(GUID$) can return a global unique identifier that can be used as unique file name too.

 

Restrictions

 

See also

 

File Module,

 

https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea

 

Examples

 

string sTemp = DIR_GetTempFileName("c:\""xxx", 42)