Theo's Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Windows Script Runtime => Source Code => Scripting => FileSystemObject => Topic started by: José Roca on July 14, 2008, 03:55:07 AM

Title: IFile.Delete Method
Post by: José Roca 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
Title: Re: IFile.Delete Method
Post by: Arthur Gomide 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.
Title: Re: IFile.Delete Method
Post by: José Roca 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$.
Title: Re: IFile.Delete Method
Post by: Arthur Gomide on February 24, 2016, 02:57:47 AM
Very thanks, José!