Author Topic: IFileSystem.GetTempName Method  (Read 2090 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2524
  • User-Rate: +209/-0
  • Gender: Male
IFileSystem.GetTempName Method
« on: July 14, 2008, 02:28:06 AM »

The following example illustrates the use of the GetTempName method.

JScript

Code: [Select]
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();

VBScript

Code: [Select]
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

PowerBASIC

Code: [Select]
LOCAL fso AS IFileSystem
LOCAL tfolder AS IFolder
LOCAL tname AS STRING
LOCAL tfile AS ITextStream

fso = NEWCOM ("Scripting.FileSystemObject")
tfolder = fso.GetSpecialFolder(%TemporaryFolder)
tname = fso.GetTempName
tfile = tfolder.CreateTextFile(tname, %VARIANT_TRUE)
tfile.WriteLine UCODE$("Hello World")
tfile.Close  
« Last Edit: July 14, 2008, 02:30:29 AM by José Roca »