ערוך

שתף באמצעות


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
FileSystem

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()

Initializes a new instance of the FileSystem class.

Properties

CurrentDirectory

Gets or sets the current directory.

Drives

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

Methods

CombinePath(String, String)

Combines two paths and returns a properly formatted path.

CopyDirectory(String, String)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, Boolean)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, UIOption)

Copies the contents of a directory to another directory.

CopyDirectory(String, String, UIOption, UICancelOption)

Copies the contents of a directory to another directory.

CopyFile(String, String)

Copies a file to a new location.

CopyFile(String, String, Boolean)

Copies a file to a new location.

CopyFile(String, String, UIOption)

Copies a file to a new location.

CopyFile(String, String, UIOption, UICancelOption)

Copies a file to a new location.

CreateDirectory(String)

Creates a directory.

DeleteDirectory(String, DeleteDirectoryOption)

Deletes a directory.

DeleteDirectory(String, UIOption, RecycleOption)

Deletes a directory.

DeleteDirectory(String, UIOption, RecycleOption, UICancelOption)

Deletes a directory.

DeleteFile(String)

Deletes a file.

DeleteFile(String, UIOption, RecycleOption)

Deletes a file.

DeleteFile(String, UIOption, RecycleOption, UICancelOption)

Deletes a file.

DirectoryExists(String)

Returns True if the specified directory exists.

Equals(Object)

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

(Inherited from Object)
FileExists(String)

Returns True if the specified file exists.

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[])

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

GetDirectories(String)

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

GetDirectories(String, SearchOption, String[])

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

GetDirectoryInfo(String)

Returns a DirectoryInfo object for the specified path.

GetDriveInfo(String)

Returns a DriveInfo object for the specified drive.

GetFileInfo(String)

Returns a FileInfo object for the specified file.

GetFiles(String)

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

GetFiles(String, SearchOption, String[])

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetName(String)

Parses the file name out of the path provided.

GetParentPath(String)

Returns the parent path of the provided path.

GetTempFileName()

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

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MoveDirectory(String, String)

Moves a directory from one location to another.

MoveDirectory(String, String, Boolean)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption, UICancelOption)

Moves a directory from one location to another.

MoveFile(String, String)

Moves a file to a new location.

MoveFile(String, String, Boolean)

Moves a file to a new location.

MoveFile(String, String, UIOption)

Moves a file to a new location.

MoveFile(String, String, UIOption, UICancelOption)

Moves a file to a new location.

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[])

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[])

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)

Opens a StreamReader object to read from a file.

OpenTextFileReader(String, Encoding)

Opens a StreamReader object to read from a file.

OpenTextFileWriter(String, Boolean)

Opens a StreamWriter object to write to the specified file.

OpenTextFileWriter(String, Boolean, Encoding)

Opens a StreamWriter to write to the specified file.

ReadAllBytes(String)

Returns the contents of a file as a byte array.

ReadAllText(String)

Returns the contents of a text file as a String.

ReadAllText(String, Encoding)

Returns the contents of a text file as a String.

RenameDirectory(String, String)

Renames a directory.

RenameFile(String, String)

Renames a file.

ToString()

Returns a string that represents the current object.

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

Writes data to a binary file.

WriteAllText(String, String, Boolean)

Writes text to a file.

WriteAllText(String, String, Boolean, Encoding)

Writes text to a file.

Applies to

See also