GetTemppath is a DOS name, when the file name is greater than 8, long file name format "C: / documents and settings / administrator / local settings / temp" will be "C: / Docume ~ 1 / Admini ~ 1 / Locals ~ 1 / Temp "short message name format, how to obtain the system temporary directory, below is a new function, call two API implementations, I believe that many friends may be available.
Option ExplicitPrivate Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As LongPrivate Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As string) as long
Sub GetTEMPfolder (Optional ByVal showlong As Boolean = True) Dim longname As String, shortname As String shortname = Space (256) GetTempPath Len (shortname), shortname longname = Space (1024) GetLongPathName shortname, longname, Len (longname)
MsgBox "TempFolder:" & IIF (showlong = true, longname, shortname) End Sub
PRIVATE SUB Command1_Click () getTempFolder 'long file name GetTempFolder false' short file name END SUB