O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FileSystemObject.GetTempName Method

Syntax

                  oFileSysObj.GetTempName
oFileSysObj

Use: Required

Data Type: FileSystemObject object

A FileSystemObject object.

Return Value

A String.

Description

Returns a system-generated temporary file or folder name.

Rules at a Glance

GetTempName doesn’t create a temporary file or folder; it simply provides a name you can use with the CreateTextFile method.

Programming Tips and Gotchas

  • As a general rule, you shouldn’t create your own temporary filenames. Windows provides an algorithm within the Windows API to generate the special temporary file and folder names so that it can recognize them later.

  • If you are calling GetTempName as the first step in creating a temporary file, you can also call the GetSpecialFolder method to retrieve the path of the temporary directory, as follows:

    Const TemporaryFolder = 2
    Dim oFS, sTempPath
    Set oFS = CreateObject("Scripting.FileSystemObject")
    sTempPath = oFS.GetSpecialFolder(TemporaryFolder)

    You can then form the complete path to the temporary folder as follows:

    <CODE>sFullPath = sTempPath & "' & sTempFileName

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required