FileSystem FileSystem FileSystem FileSystem Class

Definition

Provides properties and methods for working with drives, files, and directories.

public ref class FileSystem
public class FileSystem
type FileSystem = class
Public Class FileSystem
Inheritance
FileSystemFileSystemFileSystemFileSystem

Examples

This example checks to determine whether the folder C:\backup\logs exists and checks its properties.

Dim logInfo As System.IO.DirectoryInfo
If My.Computer.FileSystem.DirectoryExists("C:\backup\logs") Then
    logInfo = My.Computer.FileSystem.GetDirectoryInfo(
      "C:\backup\logs")
End If

Remarks

The following table lists examples of tasks involving the My.Computer.FileSystem object.

To See
Read from a text file How to: Read from Text Files
Read from a delimited text file How to: Read From Comma-Delimited Text Files
Read from a fixed-width text file How to: Read From Fixed-width Text Files
Read from a text file with multiple formats How to: Read From Text Files with Multiple Formats
Read from a binary file How to: Read From Binary Files
Read from a text file with a StreamReader How to: Read Text from Files with a StreamReader
Write to a text file How to: Write Text to Files
Append to a text file How to: Append to Text Files
Write to a binary file How to: Write to Binary Files
Write to text files in the MyDocuments directory How to: Write Text to Files in the My Documents Directory
Write to a text file with a StreamWriter How to: Write Text to Files with a StreamWriter
Copy files with a specific pattern How to: Copy Files with a Specific Pattern to a Directory
Copy a file to the same directory How to: Create a Copy of a File in the Same Directory
Copy a file to a different directory How to: Create a Copy of a File in a Different Directory
Create a file How to: Create a File
Delete a file How to: Delete a File
Find files with a specific pattern How to: Find Files with a Specific Pattern
Move a file How to: Move a File
Rename a file How to: Rename a File
Copy a directory to another directory How to: Copy a Directory to Another Directory
Create a directory How to: Create a Directory
Find subdirectories with a specific pattern How to: Find Subdirectories with a Specific Pattern
Get the collection of files in a directory How to: Get the Collection of Files in a Directory
Read from the MyDocuments directory How to: Retrieve the Contents of the My Documents Directory
Parse a file path How to: Parse File Paths

Constructors

FileSystem() FileSystem() FileSystem() FileSystem()

Initializes a new instance of the FileSystem class.

Properties

CurrentDirectory CurrentDirectory CurrentDirectory CurrentDirectory

Gets or sets the current directory.

Drives Drives Drives Drives

Returns a read-only collection of all available drive names.

Methods

CombinePath(String, String) CombinePath(String, String) CombinePath(String, String) CombinePath(String, String)

Combines two paths and returns a properly formatted path.

CopyDirectory(String, String) CopyDirectory(String, String) CopyDirectory(String, String) CopyDirectory(String, String)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, Boolean) CopyDirectory(String, String, Boolean) CopyDirectory(String, String, Boolean) CopyDirectory(String, String, Boolean)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, UIOption) CopyDirectory(String, String, UIOption) CopyDirectory(String, String, UIOption) CopyDirectory(String, String, UIOption)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, UIOption, UICancelOption) CopyDirectory(String, String, UIOption, UICancelOption) CopyDirectory(String, String, UIOption, UICancelOption) CopyDirectory(String, String, UIOption, UICancelOption)

Copies the contents of a directory to another directory.

CopyFile(String, String) CopyFile(String, String) CopyFile(String, String) CopyFile(String, String)

Copies a file to a new location.

CopyFile(String, String, Boolean) CopyFile(String, String, Boolean) CopyFile(String, String, Boolean) CopyFile(String, String, Boolean)

Copies a file to a new location.

CopyFile(String, String, UIOption) CopyFile(String, String, UIOption) CopyFile(String, String, UIOption) CopyFile(String, String, UIOption)

Copies a file to a new location.

CopyFile(String, String, UIOption, UICancelOption) CopyFile(String, String, UIOption, UICancelOption) CopyFile(String, String, UIOption, UICancelOption) CopyFile(String, String, UIOption, UICancelOption)

Copies a file to a new location.

CreateDirectory(String) CreateDirectory(String) CreateDirectory(String) CreateDirectory(String)

Creates a directory.

DeleteDirectory(String, DeleteDirectoryOption) DeleteDirectory(String, DeleteDirectoryOption) DeleteDirectory(String, DeleteDirectoryOption) DeleteDirectory(String, DeleteDirectoryOption)

Deletes a directory.

DeleteDirectory(String, UIOption, RecycleOption) DeleteDirectory(String, UIOption, RecycleOption) DeleteDirectory(String, UIOption, RecycleOption) DeleteDirectory(String, UIOption, RecycleOption)

Deletes a directory.

DeleteDirectory(String, UIOption, RecycleOption, UICancelOption) DeleteDirectory(String, UIOption, RecycleOption, UICancelOption) DeleteDirectory(String, UIOption, RecycleOption, UICancelOption) DeleteDirectory(String, UIOption, RecycleOption, UICancelOption)

Deletes a directory.

DeleteFile(String) DeleteFile(String) DeleteFile(String) DeleteFile(String)

Deletes a file.

DeleteFile(String, UIOption, RecycleOption) DeleteFile(String, UIOption, RecycleOption) DeleteFile(String, UIOption, RecycleOption) DeleteFile(String, UIOption, RecycleOption)

Deletes a file.

DeleteFile(String, UIOption, RecycleOption, UICancelOption) DeleteFile(String, UIOption, RecycleOption, UICancelOption) DeleteFile(String, UIOption, RecycleOption, UICancelOption) DeleteFile(String, UIOption, RecycleOption, UICancelOption)

Deletes a file.

DirectoryExists(String) DirectoryExists(String) DirectoryExists(String) DirectoryExists(String)

Returns True if the specified directory exists.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FileExists(String) FileExists(String) FileExists(String) FileExists(String)

Returns True if the specified file exists.

FindInFiles(String, String, Boolean, SearchOption) FindInFiles(String, String, Boolean, SearchOption) FindInFiles(String, String, Boolean, SearchOption) FindInFiles(String, String, Boolean, SearchOption)

Returns a read-only collection of strings representing the names of files containing the specified text.

FindInFiles(String, String, Boolean, SearchOption, String[]) FindInFiles(String, String, Boolean, SearchOption, String[]) FindInFiles(String, String, Boolean, SearchOption, String[]) FindInFiles(String, String, Boolean, SearchOption, String[])

Returns a read-only collection of strings representing the names of files containing the specified text.

GetDirectories(String) GetDirectories(String) GetDirectories(String) GetDirectories(String)

Returns a collection of strings representing the path names of subdirectories within a directory.

GetDirectories(String, SearchOption, String[]) GetDirectories(String, SearchOption, String[]) GetDirectories(String, SearchOption, String[]) GetDirectories(String, SearchOption, String[])

Returns a collection of strings representing the path names of subdirectories within a directory.

GetDirectoryInfo(String) GetDirectoryInfo(String) GetDirectoryInfo(String) GetDirectoryInfo(String)

Returns a DirectoryInfo object for the specified path.

GetDriveInfo(String) GetDriveInfo(String) GetDriveInfo(String) GetDriveInfo(String)

Returns a DriveInfo object for the specified drive.

GetFileInfo(String) GetFileInfo(String) GetFileInfo(String) GetFileInfo(String)

Returns a FileInfo object for the specified file.

GetFiles(String) GetFiles(String) GetFiles(String) GetFiles(String)

Returns a read-only collection of strings representing the names of files within a directory.

GetFiles(String, SearchOption, String[]) GetFiles(String, SearchOption, String[]) GetFiles(String, SearchOption, String[]) GetFiles(String, SearchOption, String[])

Returns a read-only collection of strings representing the names of files within a directory.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetName(String) GetName(String) GetName(String) GetName(String)

Parses the file name out of the path provided.

GetParentPath(String) GetParentPath(String) GetParentPath(String) GetParentPath(String)

Returns the parent path of the provided path.

GetTempFileName() GetTempFileName() GetTempFileName() GetTempFileName()

Creates a uniquely named zero-byte temporary file on disk and returns the full path of that file.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String)

Moves a directory from one location to another.

MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption)

Moves a directory from one location to another.

MoveFile(String, String) MoveFile(String, String) MoveFile(String, String) MoveFile(String, String)

Moves a file to a new location.

MoveFile(String, String, Boolean) MoveFile(String, String, Boolean) MoveFile(String, String, Boolean) MoveFile(String, String, Boolean)

Moves a file to a new location.

MoveFile(String, String, UIOption) MoveFile(String, String, UIOption) MoveFile(String, String, UIOption) MoveFile(String, String, UIOption)

Moves a file to a new location.

MoveFile(String, String, UIOption, UICancelOption) MoveFile(String, String, UIOption, UICancelOption) MoveFile(String, String, UIOption, UICancelOption) MoveFile(String, String, UIOption, UICancelOption)

Moves a file to a new location.

OpenTextFieldParser(String) OpenTextFieldParser(String) OpenTextFieldParser(String) OpenTextFieldParser(String)

The OpenTextFieldParser method allows you to create a TextFieldParser object, which provides a way to easily and efficiently parse structured text files, such as logs. The TextFieldParser object can be used to read both delimited and fixed-width files.

OpenTextFieldParser(String, Int32[]) OpenTextFieldParser(String, Int32[]) OpenTextFieldParser(String, Int32[]) OpenTextFieldParser(String, Int32[])

The OpenTextFieldParser method allows you to create a TextFieldParser object, which provides a way to easily and efficiently parse structured text files, such as logs. The TextFieldParser object can be used to read both delimited and fixed-width files.

OpenTextFieldParser(String, String[]) OpenTextFieldParser(String, String[]) OpenTextFieldParser(String, String[]) OpenTextFieldParser(String, String[])

The OpenTextFieldParser method allows you to create a TextFieldParser object, which provides a way to easily and efficiently parse structured text files, such as logs. The TextFieldParser object can be used to read both delimited and fixed-width files.

OpenTextFileReader(String) OpenTextFileReader(String) OpenTextFileReader(String) OpenTextFileReader(String)

Opens a StreamReader object to read from a file.

OpenTextFileReader(String, Encoding) OpenTextFileReader(String, Encoding) OpenTextFileReader(String, Encoding) OpenTextFileReader(String, Encoding)

Opens a StreamReader object to read from a file.

OpenTextFileWriter(String, Boolean) OpenTextFileWriter(String, Boolean) OpenTextFileWriter(String, Boolean) OpenTextFileWriter(String, Boolean)

Opens a StreamWriter object to write to the specified file.

OpenTextFileWriter(String, Boolean, Encoding) OpenTextFileWriter(String, Boolean, Encoding) OpenTextFileWriter(String, Boolean, Encoding) OpenTextFileWriter(String, Boolean, Encoding)

Opens a StreamWriter to write to the specified file.

ReadAllBytes(String) ReadAllBytes(String) ReadAllBytes(String) ReadAllBytes(String)

Returns the contents of a file as a byte array.

ReadAllText(String) ReadAllText(String) ReadAllText(String) ReadAllText(String)

Returns the contents of a text file as a String.

ReadAllText(String, Encoding) ReadAllText(String, Encoding) ReadAllText(String, Encoding) ReadAllText(String, Encoding)

Returns the contents of a text file as a String.

RenameDirectory(String, String) RenameDirectory(String, String) RenameDirectory(String, String) RenameDirectory(String, String)

Renames a directory.

RenameFile(String, String) RenameFile(String, String) RenameFile(String, String) RenameFile(String, String)

Renames a file.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
WriteAllBytes(String, Byte[], Boolean) WriteAllBytes(String, Byte[], Boolean) WriteAllBytes(String, Byte[], Boolean) WriteAllBytes(String, Byte[], Boolean)

Writes data to a binary file.

WriteAllText(String, String, Boolean) WriteAllText(String, String, Boolean) WriteAllText(String, String, Boolean) WriteAllText(String, String, Boolean)

Writes text to a file.

WriteAllText(String, String, Boolean, Encoding) WriteAllText(String, String, Boolean, Encoding) WriteAllText(String, String, Boolean, Encoding) WriteAllText(String, String, Boolean, Encoding)

Writes text to a file.

Applies to

See also