GetTempFileName()

Summary

Generates a valid and unused file name with a given specification.

Syntax

name = GetTempFileName(string path)

Argument Contents
path Null, or a full or partial path, with an optional extension

Returns

A string containing a full path, file name, and extension (if specified).

Notes

  • The path argument can be null.

  • The default path is the temporary folder returned by GetTempPath().

  • The file name is always generated for you, even if you specify a file name.

  • If an extension, with a leading period, is provided in the path argument it will be used. Otherwise, the file name will have no extension.

  • A partial path not starting with slashes will be relative to the program folder (directory).

  • A partial path starting with slashes will be relative to the root of your C: drive.

  • A path starting with "X:\\" where X is a drive letter and colon will just have the temporary file name inserted.

  • The folders in the path may have the 8.3 naming convention, with long folder names truncated to six characters plus a tilde (~) and a digit to make them unique.

  • GetTempFileName() returns the name of a file that does not exist.

  • On program shutdown, all temporary files are deleted.

Examples

// In all examples:
// - The temporary file name is shown as "ttt"
// - The user name is shown as "user"
// - The program folder is shown as "C:\Program Files\Maptitude"
tmp = GetTempFileName() // tmp = "C:\DOCUME~1\user\LOCALS~1\Temp\Maptitude\ttt"
tmp = GetTempFileName(".dbf") // tmp = "C:\DOCUME~1\xxx\LOCALS~1\Temp\Maptitude\ttt.dbf"
tmp = GetTempFileName("Temp\\.dbf") // tmp = "C:\Program Files\Maptitude\Temp\ttt.dbf"
tmp = GetTempFileName("\\Temp\\.dbf") // tmp = "C:\Temp\ttt.dbf"
tmp = GetTempFileName("E:\\Temp\\.dbf") // tmp = "E:\Temp\ttt.dbf"
tmp = GetTempFileName("H:\\MyFiles\\MyData\\") // tmp = "H:\MyFiles\MyData\ttt"

See Also

Function Summary
GetRandFileName() Generates a valid and unused file name with a given specification, but leaves all temporary files open on shutdown
GetTempPath() Gets the name of the directory used by Maptitude to store temporary files