• Welcome to Jose's Read Only Forum 2023.
 

IFile.Delete Method

Started by José Roca, July 14, 2008, 03:55:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the Delete method.

JScript


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


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


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


Arthur Gomide

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.

José Roca

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$.

Arthur Gomide