Visual Basic Concepts

Examining the File System

See Also

Each of the file-system controls has been carefully designed to combine flexible and sophisticated file-system inspection capabilities with easy programming. Each control performs its file-data retrieval tasks automatically, but you can write code both to customize their appearance and to specify which information they display.

Figure 7.16   The file-system controls

You can use file-system controls singly or in combination. With combinations, you can write code in each control's event procedures to determine how they interact. Or you can let them act independently. Figure 7.17 shows the three controls used together.

Figure 7.17   The file-system controls used together

File-system controls obtain all their information from the operating system automatically; you can access this information or determine what is displayed by each control through its properties. For example, the contents of the current working directory is displayed by default (that is, the directory from which the application was launched, or what became the current directory as the result of a ChDir statement).

Your application can also display a list of the files with names matching a pattern, such as *.frm. Simply draw a file list box on the form and set its Pattern property to *.frm. You can specify the Pattern property at run time with the following code:

File1.Pattern = "*.FRM"

The file-system controls give you the flexibility that is not available with the common dialog control. You can mix and match them in a variety of ways, and you control their appearance and how they interact.

If your goal is simply to allow users to open and save files, a common dialog control provides a ready-to-run set of dialog boxes for these and other operations. These are the same dialog boxes used by many other Microsoft Windows – based applications, so they provide a standardized look-and-feel. They also recognize network drives when they're available.

For More Information   See "Using the Common Dialog Control" earlier in this chapter for more information.