Author Topic: IFileSystem.CreateTextFile Method  (Read 2538 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.CreateTextFile Method
« on: July 14, 2008, 03:20:00 AM »

The following code illustrates how to use the CreateTextFile method to create and open a text file.

JScript

Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();

VBScript

Code: [Select]
Sub CreateAfile
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
   MyFile.WriteLine("This is a test.")
   MyFile.Close
End Sub

PowerBASIC

Code: [Select]
SUB CreateAfile

   LOCAL fso AS IFileSystem
   LOCAL MyFile AS ITextStream

   fso = NEWCOM ("Scripting.FileSystemObject")
   MyFile = fso.CreateTextFile(UCODE$("c:\testfile.txt"), %VARIANT_TRUE)
   MyFile.WriteLine(UCODE$("This is a test."))
   MyFile.Close

END SUB