Maybe something as the following
//--- Returns temporary directory name without trailing backslash
function GetTempDir()
local cTargetDir, cTempDir, cTmpDir
local lTempExist, lTmpExist
cTempDir := GetEnv( "TEMP" )
cTmpDir := GetEnv( "
TMP" )
if ( Right( cTempDir, 1 ) == "\" )
cTempDir := SubStr( cTempDir, 1, Len( cTempDir ) - 1 )
endif
if ( Right( cTmpDir, 1 ) == "\" )
cTmpDir := SubStr( cTmpDir, 1, Len( cTmpDir ) - 1 )
endif
lTempExist := .F.
if ( !empty( cTempDir ) )
if ( IsDir(cTempDir ) )
lTempExist := .T.
endif
endif
lTmpExist := .F.
if ( !empty( cTmpDir ) )
if ( IsDir(cTmpDir ) )
lTmpExist := .T.
endif
endif
do case
case ( lTempExist )
cTargetDir := cTempDir
case ( lTmpExist )
cTargetDir := cTmpDir
otherwise
cTargetDir := GetWinDir()
endcase
return ( cTargetDir )