Explorer-Style Application Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

Demonstrates

This sample contains two forms with an Explorer-like interface: a directory scanner and an Explorer-style viewer. The files that support the two forms are contained in separate folders of the project.

  • DirectoryScanner   This is a simple application that scans all directories and sub-directories in either all logical drives or a user-selected starting directory. The list of drives is obtained by using the Directory..::.GetLogicalDrives method. A tree view control displays the directory structure reflecting the latest scan. Directories are colored green, yellow, or red based on their total size inclusive of all sub-directories and files. The Directory..::.GetFiles method is used to retrieve the list of files, and the FileInfo class is used to receive the file size.

  • ExplorerStyleViewer   This is a simpler version of the Windows Explorer application. The ExplorerStyleViewer displays more file information than DirectoryScanner by using the FileSystemInfo..::.Attributes property. It demonstrates how to associate icons with file types by using the TreeView..::.ImageList property. It enables the user to run an application associated with the file type (if an association exists) by double-clicking the file (just like in Windows Explorer). Applications are started by using the Process..::.Start method.