File System Object Model (VB6)

Library to Reference

Microsoft Scripting Runtime (../ SYSTEM32/SCRRUN.DLL )

Description

For years, VB developers have been using the VBA language to perform tasks such as opening, writing, and closing files, but with VB6, that's about to change. Of course, for backward compatibility, all the original file and directory manipulation statements and functions are still there, but now VB includes the File System object model, a rich object model for local and network file access.

The File System object model is itself not an intrinsic part of the VBA language, but is part of the Scripting Runtime library. Those of you familiar with VBScript may recognize the original components of the File System object model, a very basic version of which first appeared in Version 2 of the Scripting Runtime library, when the model simply contained a top-level object, the FileSystemObject object, and the TextStream object. Version 4 of the Scripting Runtime that ships with VB6 contains a full object model that represents all drives that are attached to the computer, including hard drives, floppy and removable media drives, RAM drives, CD-ROM drives, and drives on other machines. The File System object model allows you to interrogate, create, delete, and otherwise manipulate folders and text files. The depth of information that is provided within the object model would have forced you to resort to the Win32 API in previous versions of VB.

To access the File System object model, you must use the References dialog to add a reference to the Microsoft Scripting Runtime library to your project. You can then create an instance of the FileSystemObject object, the only externally createable object in the model. From there, you can navigate through the object model, as shown in the object hierarchy diagram in Figure 7.4.

Figure 7.4. The File System object model

If you are dealing with random access files, the intrinsic VB language functions and statements are still the way to go, since the File System object only directly opens text files using the TextStream object.

See Also

File Object, Files Collection Object, FileSystemObject Object, Folder Object, Folders Collection, TextStream Object
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.38.232