Pages

Tuesday, 18 October 2011

Get Temporary File Name



' =============================================================
' function: GetTemporaryFileName
' desc    : Generates a unique file name in the windows 
'           temporary folder
' params  : none
' returns : A unique temporary file, including path
' =============================================================

Function GetTemporaryFileName

Const TemporaryFolder = 2

Dim objFS
Dim objTempFolder

' create the file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

' get the path to the temporary folder
Set objTempFolder = objFS.GetSpecialFolder(TemporaryFolder)

' return the path plus a unique temporary file name
GetTemporaryFileName = objTempFolder.Path & "\" & objFS.GetTempName

' destroy the object
Set objFS = Nothing
Set objTempFolder = Nothing

End Function 'GetTemporaryFileName

0 comments:

Post a Comment