Locate the Temp Folder

Locate the Temp Folder

In your apps, do the right thing: Use the computer’s Temp folder to hold your temporary files. To find that location, paste this code into the Declarations section of a form:

 Private Declare Function GetTempPath Lib _	"kernel32" Alias "GetTempPathA" (ByVal _	nBufferLength As Long, ByVal lpBuffer As _	String) As LongPrivate Const MAX_PATH = 260Public Property Get TempPathLocation() As String	Dim sBuffer As String	sBuffer = Space(MAX_PATH)	If GetTempPath(MAX_PATH, sBuffer)  0 Then		TempPathLocation = Left$(sBuffer, _			InStr(sBuffer, vbNullChar) - 1)	Else		TempPathLocation = ""	End IfEnd Property

This routine returns the computer’s established Temp folder. If none has been established, an empty string is returned, which may be interpreted as the current directory. Be sure to use Kill on all created temp files when you’re through with them.


Share the Post: