Author Topic: IFile.Delete Method  (Read 3575 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
IFile.Delete Method
« on: July 14, 2008, 03:55:07 AM »

The following example illustrates the use of the Delete method.

JScript

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

VBScript

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

PowerBASIC

Code: [Select]
DIM fso AS IFileSystem
DIM MyFile AS IFile
MyFile = fso.CreateTextFile(UCODE$("c:\testfile.txt"), %VARIANT_TRUE)
MyFile.WriteLine(UCODE$(("This is a test."))
MyFile.Close
MyFile = fso.GetFile(UCODE$("c:\testfile.txt"))
MyFile.Delete

Offline Arthur Gomide

  • Newbie
  • *
  • Posts: 3
  • User-Rate: +0/-0
Re: IFile.Delete Method
« Reply #1 on: February 23, 2016, 11:29:55 PM »
Hi Jose,

For some reason I got "Untrapped Error #99 (Object error)", even with a valid file. I'm using your include files #107 with W7/64.

Thanks for your attention.

Arthur.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Re: IFile.Delete Method
« Reply #2 on: February 24, 2016, 12:52:00 AM »
These examples were for PBWIN 9.0/PBCC 5.0, when unicode was not still natively implemented. With the latest compilers and include files you must get rid of UCODE$/ACODE$.

Offline Arthur Gomide

  • Newbie
  • *
  • Posts: 3
  • User-Rate: +0/-0
Re: IFile.Delete Method
« Reply #3 on: February 24, 2016, 02:57:47 AM »
Very thanks, José!