File System: Accessing the File System

Demonstrates the DirectoryInfo/Directory and FileInfo/File classes. 

Featured Highlights

This demonstration allows you to dig through a TreeView control containing directory and file system information, selecting directories or files and viewing information about the selected object. In particular, this demonstration shows off some shared members of the DirectoryInfo and FileInfo classes, along with instance members of the classes. In addition, the example uses the fact that both DirectoryInfo and FileInfo object inherit from the FileSystemInfo class, using a single procedure to display information about either type of object. 

Requirements

Requires the Trial or Release version of Visual Studio .NET Professional (or greater).

Running the Sample

Note the comments within the sample—handling the appearance of the "+" signs in the TreeView control takes a little extra effort. This example uses one technique for handling the display of the control, and there are other techniques, as well. The comments explain the logic.

Note that if a device is not ready (such as a floppy drive), the + sign will be removed. Press F5 or select Refresh from the File menu to re-check for loaded media. 

Last Update: 7 July 2002