Microsoft® Visual Basic® Scripting Edition GetTempName Method | Language Reference Version 3

See Also Applies To

##### Description

> Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder.

##### Syntax

> object.GetTempName

> The optional object is always the name of a FileSystemObject.

##### Remarks

> The GetTempName method does not create a file. It provides only a temporary file name that can be used with CreateTextFile to create a file.

> The following example illustrates use of the GetTempName method:

> >     Dim fso, tempfile
> >     Set fso = CreateObject("Scripting.FileSystemObject")

> >     Function CreateTempFile
> >        Dim tfolder, tname, tfile
> >        Const TemporaryFolder = 2
> >        Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
> >        tname = fso.GetTempName
> >        Set tfile = tfolder.CreateTextFile(tname)
> >        Set CreateTempFile = tfile
> >     End Function

> >     Set tempfile = CreateTempFile
> >     tempfile.WriteLine "Hello World"
> >     tempfile.Close

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.