Share this page 

Determine the TEMP directory designated for temporary files.Tag(s): Powerscript

In PB6, simply get the value of the environment variable TEMP
ContextKeyword lcxk_base
string ls_temp[]

this.GetContextService("Keyword", lcxk_base)
lcxk_base.getContextKeywords("TEMP", ls_temp)
RETURN ls_temp[1]
Or you can use the following API call
[External function declaration]
FUNCTION ulong GetTempPath(ulong nBufferLength, ref string lpBuffer) &
   LIBRARY "kernel32" ALIAS FOR GetTempPathA
long ll_bufferlength = 256
string ls_tempDir

ls_tempDir = SPACE(ll_bufferLength)

IF GetTempPath(ll_bufferLength, ls_tempDir) = 0 THEN
    MessageBox("Temp dir", "not defined")
    MessageBox("Temp dir", ls_tempDir)
The GetTempPath function gets the temporary file path as follows:
  • The path specified by the TMP environment variable.
  • The path specified by the TEMP environment variable, if TMP is not defined.
  • The current directory, if both TMP and TEMP are not defined.