My.Computer.FileSystem


The My.Computer.FileSystem object provides tools for working with drives, directories, and files. The following table summarizes this object’s properties.

Open table as spreadsheet

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 the section “DriveInfo” earlier in this chapter for information about the Drive?Info 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 MyDocuments directory). See the section “My.Computer .FileSystem.SpecialDirectories” later in this chapter for more information.

The following list describes the My.Computer.FileSystem object’s methods.

Open table as spreadsheet

Method

Purpose

CombinePath

Combines a base path with a relative path reference and returns a properly formatted fully qualified path. For example, the following code displays the name of the directory that is the parent of the application’s current directory:

 MessageBox.Show( _     My.Computer.FileSystem.CombinePath( _ My.Computer.FileSystem.CurrentDirectory(), _         "..")

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 a directory. This method will create ancestor directories if necessary. For example, if the C:\Temp directory contains no subdirectories, creating C:\Temp\ Project\Data will automatically create C:\Temp\Project and C:\Temp\Project\Data.

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 read-only collection of strings listing files that contain a target string.

GetDirectories

Returns a string collection listing subdirectories of a given directory. Parameters tell whether to recursively search the subdirectories, and the wildcards to match.

GetDirectoryInfo

Returns a DirectoryInfo object for a directory. See the section “DirectoryInfo” earlier in this chapter for more information.

GetDriveInfo

Returns a DriveInfo object for a drive. See the section “DriveInfo” earlier in this chapter for more information.

GetFileInfo

Returns a FileInfo object for a file. See the section “FileInfo” earlier in this chapter 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 of the bytes from a binary file into an array.

ReadAllText

Reads all of 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.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net