5.3. Copy, Move, or Delete a File or a Directory


You need to copy, move, or delete a file or directory.


You have two main options for manipulating files and directories. One option is to create a System. IO.FileInfo object for a file or a System.IO.DirectoryInfo object for a directory, supplying the path in the constructor. You can then use the object's methods to copy, move, and delete the file or directory. Alternatively, you can use the My.Computer.FileSystem class and its Shared methods.

How It Works

The FileInfo, DirectoryInfo, and My.Computer.FileSystem classes include a host of valuable methods for manipulating files and directories. Table 5-3 shows methods for the FileInfo class, Table 5-4 shows methods for the DirectoryInfo ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.