devxlogo

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.

See also  How College Students Can Shape the Future of Tech Responsibility
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist