Chapter 37. File-System Objects

Visual Basic includes a bewildering assortment of objects that you can use to manipulate drives, directories, and files. The stream classes described in Chapter 36 enable you to read and write files, but they don't really capture any of the special structure of the file system.

A Visual Basic application has two main choices for working with the file system: Visual Basic methods and .NET Framework classes. This chapter describes these two approaches and the classes that they use. It finishes by describing some of the My namespace properties and methods that you can use to access file-system tools more easily. For more information on the My namespace, see the section "My" in Chapter 35, "Configuration and Resources," and Appendix S, "The My Namespace."

PERMISSIONS

An application cannot perform a task if the user running it doesn't have the appropriate permissions. Although this is true of any operation a program must perform, permission issues are particularly common when working with files, and recent versions of the Windows operating system are particularly strict about enforcing permission requirements.

A common mistake is for developers to build and test an application while logged in as a user who has a lot of privileges. Sometimes, developers even have system administrator privileges, so their programs can do pretty much anything on the computer. To ensure that users will have the permissions needed by an application, develop or at least test the ...

Get Visual Basic® 2010 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.