function that return the temp directory of the logged user

User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Enrico,

There is a downside to putting temp files in the current directory when the program is being run from a server. This slows down the application.

It might be better (when TEMP isn't found) to check for c:\temp and if it doesn't exist, then create it and use this instead.

I know most Windows versions have a c:\windows\temp but some versions have security which won't allow users write access to it.

There is also an upside to using the server to hold temp files, and that is that any orphan temp files can be periodically deleted either by the application or an administrator.

James
Vladimir Grigoriev
Posts: 54
Joined: Fri Oct 21, 2005 10:45 am
Location: Russia, Moscow
Contact:

Post by Vladimir Grigoriev »

After reading I can conclude that idea to have a program parameter which specifies a temp directory (for example, MyProg /TMP:c:\somepath) deserves consideration. :D
Mdandrea
Posts: 21
Joined: Wed Nov 23, 2005 12:24 am

Post by Mdandrea »

Or you can use the following API call to get the windows temp folder IF they have access to it.

function get_temp()
local tbuffer:=space(256)

gettemppath(256,@tbuffer)
tbuffer := LEFT(tbuffer,AT(CHR(0),tbuffer)-1)
return(tbuffer)

DLL32 Function GetTempPath( bufferlen as LONG, tbuffer AS LPSTR) AS LONG ;
PASCAL FROM "GetTempPathA" LIB "kernel32.dll"
Post Reply