Summary


Visual Basic provides a native set of methods for reading and writing files, including FreeFile, FileOpen, Input, LineInput, Print, Write, and FileClose. It also provides method for working with the file system (such as ChDir, MkDir, Kill, and RmDir). If you have a lot of previous experience with Visual Basic, you may prefer these familiar methods.

The System.IO namespace offers many objects that provide even more powerful capabilities than the native methods of Visual Basic. Classes such as Directory, DirectoryInfo, File, and FileInfo make it easy to create, examine, move, rename, and delete directories and files. The File class’s methods make it particularly easy to read or write an entire file and to create streams attached to files for reading or writing.

The FileSystemWatcher class lets an application keep an eye on a file or directory and take action when it is changed. For example, a program can watch a spooling directory and take action when a new file appears in it.

The Path class provides miscellaneous support for working with paths. For example, it provides methods for examining a path’s file name or extension.

The My.Computer.FileSystem namespace provides shortcuts to some of the more useful of the methods offered by the other file system classes. Its methods let you create, examine, and delete files and directories. The SpecialDirectories object also provides information about the locations of system directories.

There is considerable overlap among all of these tools, so you don’t need to feel that you have to use them all. Take a good look so you know what’s there, and then pick the tools that you find the most comfortable.

The tools described in this chapter allow you fairly unstructured access to files. These classes and methods let you do just about anything you want to a file. That flexibility, however, means that you must know exactly what you want to do to the file. By letting you do anything, these tools make you do everything.

Sometimes a little more structure can make solving a problem easier. Chapter 30 describes a development structure that the .NET Framework provides to make managing certain kinds of applications called workflows easier.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net