FileSystem Class

 

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

Namespace:   Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

System::Object
  Microsoft.VisualBasic.FileIO::FileSystem

[HostProtectionAttribute(SecurityAction::LinkDemand, Resources = HostProtectionResource::ExternalProcessMgmt)]
public ref class FileSystem 

NameDescription
System_CAPS_pubmethodFileSystem()

Initializes a new instance of the FileSystem class.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticCurrentDirectory

Gets or sets the current directory.

System_CAPS_pubpropertySystem_CAPS_staticDrives

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

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticCombinePath(String^, String^)

Combines two paths and returns a properly formatted path.

System_CAPS_pubmethodSystem_CAPS_staticCopyDirectory(String^, String^)

Copies the contents of a directory to another directory.

System_CAPS_pubmethodSystem_CAPS_staticCopyDirectory(String^, String^, Boolean)

Copies the contents of a directory to another directory.

System_CAPS_pubmethodSystem_CAPS_staticCopyDirectory(String^, String^, UIOption)

Copies the contents of a directory to another directory.

System_CAPS_pubmethodSystem_CAPS_staticCopyDirectory(String^, String^, UIOption, UICancelOption)

Copies the contents of a directory to another directory.

System_CAPS_pubmethodSystem_CAPS_staticCopyFile(String^, String^)

Copies a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticCopyFile(String^, String^, Boolean)

Copies a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticCopyFile(String^, String^, UIOption)

Copies a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticCopyFile(String^, String^, UIOption, UICancelOption)

Copies a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticCreateDirectory(String^)

Creates a directory.

System_CAPS_pubmethodSystem_CAPS_staticDeleteDirectory(String^, DeleteDirectoryOption)

Deletes a directory.

System_CAPS_pubmethodSystem_CAPS_staticDeleteDirectory(String^, UIOption, RecycleOption)

Deletes a directory.

System_CAPS_pubmethodSystem_CAPS_staticDeleteDirectory(String^, UIOption, RecycleOption, UICancelOption)

Deletes a directory.

System_CAPS_pubmethodSystem_CAPS_staticDeleteFile(String^)

Deletes a file.

System_CAPS_pubmethodSystem_CAPS_staticDeleteFile(String^, UIOption, RecycleOption)

Deletes a file.

System_CAPS_pubmethodSystem_CAPS_staticDeleteFile(String^, UIOption, RecycleOption, UICancelOption)

Deletes a file.

System_CAPS_pubmethodSystem_CAPS_staticDirectoryExists(String^)

Returns True if the specified directory exists.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticFileExists(String^)

Returns True if the specified file exists.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticFindInFiles(String^, String^, Boolean, SearchOption)

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

System_CAPS_pubmethodSystem_CAPS_staticFindInFiles(String^, String^, Boolean, SearchOption, array<String^>^)

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

System_CAPS_pubmethodSystem_CAPS_staticGetDirectories(String^)

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

System_CAPS_pubmethodSystem_CAPS_staticGetDirectories(String^, SearchOption, array<String^>^)

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

System_CAPS_pubmethodSystem_CAPS_staticGetDirectoryInfo(String^)

Returns a DirectoryInfo object for the specified path.

System_CAPS_pubmethodSystem_CAPS_staticGetDriveInfo(String^)

Returns a DriveInfo object for the specified drive.

System_CAPS_pubmethodSystem_CAPS_staticGetFileInfo(String^)

Returns a FileInfo object for the specified file.

System_CAPS_pubmethodSystem_CAPS_staticGetFiles(String^)

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

System_CAPS_pubmethodSystem_CAPS_staticGetFiles(String^, SearchOption, array<String^>^)

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

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetName(String^)

Parses the file name out of the path provided.

System_CAPS_pubmethodSystem_CAPS_staticGetParentPath(String^)

Returns the parent path of the provided path.

System_CAPS_pubmethodSystem_CAPS_staticGetTempFileName()

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

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticMoveDirectory(String^, String^)

Moves a directory from one location to another.

System_CAPS_pubmethodSystem_CAPS_staticMoveDirectory(String^, String^, Boolean)

Moves a directory from one location to another.

System_CAPS_pubmethodSystem_CAPS_staticMoveDirectory(String^, String^, UIOption)

Moves a directory from one location to another.

System_CAPS_pubmethodSystem_CAPS_staticMoveDirectory(String^, String^, UIOption, UICancelOption)

Moves a directory from one location to another.

System_CAPS_pubmethodSystem_CAPS_staticMoveFile(String^, String^)

Moves a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticMoveFile(String^, String^, Boolean)

Moves a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticMoveFile(String^, String^, UIOption)

Moves a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticMoveFile(String^, String^, UIOption, UICancelOption)

Moves a file to a new location.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFieldParser(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.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFieldParser(String^, array<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.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFieldParser(String^, array<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.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFileReader(String^)

Opens a StreamReader object to read from a file.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFileReader(String^, Encoding^)

Opens a StreamReader object to read from a file.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFileWriter(String^, Boolean)

Opens a StreamWriter object to write to the specified file.

System_CAPS_pubmethodSystem_CAPS_staticOpenTextFileWriter(String^, Boolean, Encoding^)

Opens a StreamWriter to write to the specified file.

System_CAPS_pubmethodSystem_CAPS_staticReadAllBytes(String^)

Returns the contents of a file as a byte array.

System_CAPS_pubmethodSystem_CAPS_staticReadAllText(String^)

Returns the contents of a text file as a String.

System_CAPS_pubmethodSystem_CAPS_staticReadAllText(String^, Encoding^)

Returns the contents of a text file as a String.

System_CAPS_pubmethodSystem_CAPS_staticRenameDirectory(String^, String^)

Renames a directory.

System_CAPS_pubmethodSystem_CAPS_staticRenameFile(String^, String^)

Renames a file.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticWriteAllBytes(String^, array<Byte>^, Boolean)

Writes data to a binary file.

System_CAPS_pubmethodSystem_CAPS_staticWriteAllText(String^, String^, Boolean)

Writes text to a file.

System_CAPS_pubmethodSystem_CAPS_staticWriteAllText(String^, String^, Boolean, Encoding^)

Writes text to a file.

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 in Visual Basic

Read from a delimited text file

How to: Read From Comma-Delimited Text Files in Visual Basic

Read from a fixed-width text file

How to: Read From Fixed-width Text Files in Visual Basic

Read from a text file with multiple formats

How to: Read From Text Files with Multiple Formats in Visual Basic

Read from a binary file

How to: Read From Binary Files in Visual Basic

Read from a text file with a StreamReader

How to: Read Text from Files with a StreamReader (Visual Basic)

Write to a text file

How to: Write Text to Files in Visual Basic

Append to a text file

How to: Append to Text Files in Visual Basic

Write to a binary file

How to: Write to Binary Files in Visual Basic

Write to text files in the MyDocuments directory

How to: Write Text to Files in the My Documents Directory in Visual Basic

Write to a text file with a StreamWriter

How to: Write Text to Files with a StreamWriter in Visual Basic

Copy files with a specific pattern

How to: Copy Files with a Specific Pattern to a Directory in Visual Basic

Copy a file to the same directory

How to: Create a Copy of a File in the Same Directory in Visual Basic

Copy a file to a different directory

How to: Create a Copy of a File in a Different Directory in Visual Basic

Create a file

How to: Create a File in Visual Basic

Delete a file

How to: Delete a File in Visual Basic

Find files with a specific pattern

How to: Find Files with a Specific Pattern in Visual Basic

Move a file

How to: Move a File in Visual Basic

Rename a file

How to: Rename a File in Visual Basic

Copy a directory to another directory

How to: Copy a Directory to Another Directory in Visual Basic

Create a directory

How to: Create a Directory in Visual Basic

Find subdirectories with a specific pattern

How to: Find Subdirectories with a Specific Pattern in Visual Basic

Get the collection of files in a directory

How to: Get the Collection of Files in a Directory in Visual Basic

Read from the MyDocuments directory

How to: Retrieve the Contents of the My Documents Directory in Visual Basic

Parse a file path

How to: Parse File Paths in Visual Basic

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

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: