0% found this document useful (0 votes)
13 views1 page

Complete-Reference-Vb Net 36

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Complete-Reference-Vb Net 36

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Files and Directories

in this section. This section also covers the key file operation classes, such as file access
enumerations, file mode enumerations, file information classes, directory information classes, and so
on. The principal classes discussed here are File, FileInfo, Directory, DirectoryInfo, and Path. File,
Directory, and Path descend directly from System.Object while FileInfo and DirectoryInfo are
descendants of FileSystemInfo. We also look at BinaryReader and BinaryWriter, which also
derive from System.Object.For the nostalgic, I will discuss briefly .NET's support for the classic
FileSystemObject, aka FSO, which has been the mainstay API of classic VB file system
programming for some time now.
• Streams This section discusses the classes that support data streaming, reading and writing data to
objects and devices, and so on. The principal class discussed here is FileStream. Most of the
stream−utility classes derive from System.IO.Stream.
• Readers and Writers This section covers the text readers and writers that are available to you. They
derive from System.IO.TextWriter and System.IO.TextReader. We will also discuss how these
readers and writers can be bridged to various classes and objects like File and StringBuilder.

Let's begin our sojourn into .NET data processing by discussing basic file operations first. You also need a
good understanding of how file processing works before working with the Stream objects, because streams
objects are bridged to file operations.

Files and Directories


An application devoid of support for files and directories is like a vehicle without wheels or a boat without a
propeller. Simply put, it's not going anywhere. There are a lot of cool things in .NET in general and Visual
Basic .NET in particular that you don't need to have an initial grounding in. A thorough understanding of the
core elements and concepts discussed in this book will help you get up to speed on them quickly. But I deem
it essential that you become totally immersed in .NET's file handling and I/O support before the opening bell
(before you start a .NET paying project), or you'll be declared a TKO by the end of round 1.

There are two approaches to coding against the file and directory libraries that ship with the .NET Framework.
You can reference static operations classes (File, Directory, and Path), or you can create file and directory
objects using the FileInfo and DirectoryInfo classes. (Refer to Chapter 9 if you are unsure of the difference
between an operations class and a class that can be instantiatedthat is, activated as an object).

For many operations, you can simply use the static or shared classes, but there will be many reasons to work
with file and folder objects. For starters, if you herald from the world−wide sister−brotherhood of classic VB
programmer you'll probably be very familiar with the File System Object (FSO). Most established VB
programmers use the FSO all the time. Both FileInfo and DirectoryInfo let you code against a similar and
thus familiar object model as the FSO.

If you are not familiar with file and directory object models, consider the objects as objects that represent files
or directories, or abstractions thereof. An operations class is somewhat disconnected from the file or directory
you intend to work on, but a file or directory object is more like a programmable file or directory object, with
a layer you can code against.

Note The .NET Framework and the CLR obviate the need for loading and reading files for
application initialization (refer to the section "Working with Configuration Files" in Chapter
17).

520

You might also like