GetTempName Method
Returns a randomly generated temporary file or folder name that is useful for performing operations that require a temporary file or folder.
object.GetTempName ( )
Remarks
The optional object is always the name of a FileSystemObject.
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 the use of the GetTempName method.
var fso, tempfile;
fso = new ActiveXObject("Scripting.FileSystemObject");
function CreateTempFile()
{
var tfolder, tfile, tname, fname, TemporaryFolder = 2;
tfolder = fso.GetSpecialFolder(TemporaryFolder);
tname = fso.GetTempName();
tfile = tfolder.CreateTextFile(tname);
return(tfile);
}
tempfile = CreateTempFile();
tempfile.writeline("Hello World");
tempfile.close();
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