The My.Computer.FileSystem object provides tools for working with drives, directories, and files. The following table summarizes this object’s properties.
Property | Description |
---|---|
CurrentDirectory | Gets or sets the fully qualified path to the application’s current directory. |
Drives | Returns a read-only collection of DriveInfo objects describing the system’s drives. See Chapter 29 for information about the DriveInfo class. |
SpecialDirectories | Returns a SpecialDirectoriesProxy object that has properties giving the locations of various special directories such as the system’s temporary directory and the user’s My Documents directory. See the section “My.Computer.FileSystem .SpecialDirectories” later in this appendix for more information. |
The following list summarizes the My.Computer.FileSystem object’s methods.
Method | Purpose |
---|---|
CombinePath | Combines a base path with a relative path reference and returns a properly formatted fully qualified path. |
CopyDirectory | Copies a directory. Parameters indicate whether to overwrite existing files, whether to display a progress indicator, and what to do if the user presses Cancel during the operation. |
CopyFile | Copies a file. Parameters indicate whether to overwrite existing files, whether to display a progress indicator, and what to do if the user presses Cancel during the operation. |
CreateDirectory | Creates all of the directories along a path. |
DeleteDirectory | Deletes a directory. Parameters indicate whether to recursively delete subdirectories, prompt the user for confirmation, or move the directory into the Recycle Bin. |
DeleteFile | Deletes a file. Parameters indicate whether to prompt the user for confirmation, or move the file into the Recycle Bin, and what to do if the user presses Cancel while the deletion is in progress. |
DirectoryExists | Returns True if a specified directory exists. |
FileExists | Returns True if a specified file exists. |
FindInFiles | Returns a collection holding names of files that contain a search string. |
GetDirectories | Returns a string collection listing subdirectories of a given directory. Parameters tell whether to recursively search the subdirectories, and wildcards to match. |
GetDirectoryInfo | Returns a DirectoryInfo object for a directory. See the section “DirectoryInfo” earlier in this appendix for more information. |
GetDriveInfo | Returns a DriveInfo object for a drive. See the section “DriveInfo” earlier in this appendix for more information. |
GetFileInfo | Returns a FileInfo object for a file. See the section “FileInfo” earlier in this appendix for more information. |
GetFiles | Returns a string collection holding the names of files within a directory. Parameters indicate whether the search should recursively search subdirectories and give wildcards to match. |
GetParentPath | Returns the fully qualified path of a path’s parent. For example, this returns a file’s or directory’s parent directory. |
MoveDirectory | Moves a directory. Parameters indicate whether to overwrite files that have the same name in the destination directory and whether to prompt the user when such a collision occurs. |
MoveFile | Moves a file. Parameters indicate whether to overwrite a file that has the same name as the file’s destination and whether to prompt the user when such a collision occurs. |
OpenTextFieldParser | Opens a TextFieldParser object attached to a delimited or fixed-field file (such as a log file). You can use the object to parse the file. |
OpenTextFileReader | Opens a StreamReader object attached to a file. You can use the object to read the file. |
OpenTextFileWriter | Opens a StreamReader object attached to a file. You can use the object to write into the file. |
ReadAllBytes | Reads all the bytes from a binary file into an array. |
ReadAllText | Reads all the text from a text file into a string. |
RenameDirectory | Renames a directory within its parent directory. |
RenameFile | Renames a file with its directory. |
WriteAllBytes | Writes an array of bytes into a binary file. A parameter tells whether to append the data or rewrite the file. |
WriteAllText | Writes a string into a text file. A parameter tells whether to append the string or rewrite the file. |