Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Sep 30, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 Long
Private Const MAX_PATH = 260

Public 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)
		TempPathLocation = ""
	End If
End 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.
Robert Smith
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date