Bewerken

Share via


FileSystem Class

Definition

The FileSystem module contains the procedures that are used to perform file, directory or folder, and system operations. The My feature gives you better productivity and performance in file I/O operations than using the FileSystem module. For more information, see FileSystem.

public ref class FileSystem sealed
[Microsoft.VisualBasic.CompilerServices.StandardModule]
public sealed class FileSystem
[Microsoft.VisualBasic.CompilerServices.StandardModule]
[System.Security.SecurityCritical]
public sealed class FileSystem
[<Microsoft.VisualBasic.CompilerServices.StandardModule>]
type FileSystem = class
[<Microsoft.VisualBasic.CompilerServices.StandardModule>]
[<System.Security.SecurityCritical>]
type FileSystem = class
Public Module FileSystem
Inheritance
FileSystem
Attributes

Examples

This example uses the GetAttr function to determine the attributes of a file and directory or folder.

Dim MyAttr As FileAttribute
' Assume file TESTFILE is normal and readonly.
MyAttr = GetAttr("C:\TESTFILE.txt")   ' Returns vbNormal.

' Test for normal.
If (MyAttr And FileAttribute.Normal) = FileAttribute.Normal Then
    MsgBox("This file is normal.")
End If

' Test for normal and readonly.
Dim normalReadonly As FileAttribute
normalReadonly = FileAttribute.Normal Or FileAttribute.ReadOnly
If (MyAttr And normalReadonly) = normalReadonly Then
    MsgBox("This file is normal and readonly.")
End If

' Assume MYDIR is a directory or folder.
MyAttr = GetAttr("C:\MYDIR")
If (MyAttr And FileAttribute.Directory) = FileAttribute.Directory Then
    MsgBox("MYDIR is a directory")
End If

Remarks

This module supports the Visual Basic language keywords and run-time library members that access files and folders.

Methods

ChDir(String)

Changes the current directory or folder. The My feature gives you better productivity and performance in file I/O operations than the ChDir function. For more information, see CurrentDirectory .

ChDrive(Char)

Changes the current drive.

ChDrive(String)

Changes the current drive.

CurDir()

Returns a string representing the current path. The FileSystem gives you better productivity and performance in file I/O operations than CurDir. For more information, see CurrentDirectory.

CurDir(Char)

Returns a string representing the current path. The FileSystem gives you better productivity and performance in file I/O operations than CurDir. For more information, see CurrentDirectory.

Dir()

Returns a string representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive. The FileSystem gives you better productivity and performance in file I/O operations than the Dir function. See GetDirectoryInfo(String) for more information.

Dir(String, FileAttribute)

Returns a string representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive. The FileSystem gives you better productivity and performance in file I/O operations than the Dir function. See GetDirectoryInfo(String) for more information.

EOF(Int32)

Returns a Boolean value True when the end of a file opened for Random or sequential Input has been reached.

Equals(Object)

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

(Inherited from Object)
FileAttr(Int32)

Returns an enumeration representing the file mode for files opened using the FileOpen function. The FileSystem gives you better productivity and performance in file I/O operations than the FileAttr function. See GetFileInfo(String) for more information.

FileClose(Int32[])

Concludes input/output (I/O) to a file opened using the FileOpen function. My gives you better productivity and performance in file I/O operations. See FileSystem for more information.

FileCopy(String, String)

Copies a file. The FileSystem gives you better productivity and performance in file I/O operations than FileCopy. See CopyFile(String, String) for more information.

FileDateTime(String)

Returns a Date value that indicates the date and time a file was written to. The My feature gives you better productivity and performance in file I/O operations than FileDateTime. For more information, see GetFileInfo(String).

FileGet(Int32, Array, Int64, Boolean, Boolean)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Boolean, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Byte, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Char, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, DateTime, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Decimal, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Double, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int16, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int32, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int64, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Single, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, String, Int64, Boolean)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, ValueType, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGetObject(Int32, Object, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGetObject. For more information, see FileSystem.

FileLen(String)

Returns a value that specifies the length of a file in bytes. The My feature gives you better productivity and performance in file I/O operations than FileLen. For more information, see GetFileInfo(String).

FileOpen(Int32, String, OpenMode, OpenAccess, OpenShare, Int32)

Opens a file for input or output. The My feature gives you better productivity and performance in file I/O operations than FileOpen. For more information, see FileSystem.

FilePut(Int32, Array, Int64, Boolean, Boolean)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Boolean, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Byte, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Char, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, DateTime, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Decimal, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Double, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Int16, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Int32, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Int64, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, Single, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, String, Int64, Boolean)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Int32, ValueType, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePut(Object, Object, Object)
Obsolete.
Obsolete.
Obsolete.

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePut. For more information, see FileSystem.

FilePutObject(Int32, Object, Int64)

Writes data from a variable to a disk file. The My feature gives you better productivity and performance in file I/O operations than FilePutObject. For more information, see FileSystem.

FileWidth(Int32, Int32)

Assigns an output line width to a file opened by using the FileOpen function.

FreeFile()

Returns an Integer value that represents the next file number available for use by the FileOpen function.

GetAttr(String)

Returns a FileAttribute value that represents the attributes of a file, directory, or folder. The My feature gives you better productivity and performance in file I/O operations than FileAttribute. For more information, see FileSystem.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
Input(Int32, Boolean)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Byte)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Char)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, DateTime)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Decimal)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Double)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int16)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int32)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int64)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Object)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Single)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, String)

Reads data from an open sequential file and assigns the data to variables.

InputString(Int32, Int32)

Returns String value that contains characters from a file opened in Input or Binary mode. The My feature gives you better productivity and performance in file I/O operations than InputString. For more information, see FileSystem.

Kill(String)

Deletes files from a disk. The My feature gives you better productivity and performance in file I/O operations than Kill. For more information, see FileSystem .

LineInput(Int32)

Reads a single line from an open sequential file and assigns it to a String variable.

Loc(Int32)

Returns a value that specifies the current read/write position in an open file.

Lock(Int32, Int64, Int64)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

Lock(Int32, Int64)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

Lock(Int32)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

LOF(Int32)

Returns the size, in bytes, of a file opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than LOF. For more information, see FileSystem.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MkDir(String)

Creates a new directory. The My feature gives you better productivity and performance in file I/O operations than MkDir. For more information, see CreateDirectory(String).

Print(Int32, Object[])

Writes display-formatted data to a sequential file.

PrintLine(Int32, Object[])

Writes display-formatted data to a sequential file.

Rename(String, String)

Renames a disk file or directory. The My feature gives you better productivity and performance in file I/O operations than Rename. For more information, see FileSystem.

Reset()

Closes all disk files opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than Reset. For more information, see FileSystem.

RmDir(String)

Removes an existing directory. The My feature gives you better productivity and performance in file I/O operations than RmDir. For more information, see DeleteDirectory.

Seek(Int32, Int64)

Returns a Long specifying the current read/write position in a file opened by using the FileOpen function, or sets the position for the next read/write operation in a file opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than Seek. For more information, see FileSystem.

Seek(Int32)

Returns a Long specifying the current read/write position in a file opened by using the FileOpen function, or sets the position for the next read/write operation in a file opened by using the FileOpen function. The My feature gives you better productivity and performance in file I/O operations than Seek. For more information, see FileSystem.

SetAttr(String, FileAttribute)

Sets attribute information for a file. The My feature gives you better productivity and performance in file I/O operations than SetAttr. For more information, see FileSystem.

SPC(Int16)

Used with the Print or PrintLine function to position output.

TAB()

Used with the Print or PrintLine functions to position output.

TAB(Int16)

Used with the Print or PrintLine functions to position output.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
Unlock(Int32, Int64, Int64)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

Unlock(Int32, Int64)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

Unlock(Int32)

Controls access by other processes to all or part of a file opened by using the Open function. The My feature gives you better productivity and performance in file I/O operations than Lock and Unlock. For more information, see FileSystem.

Write(Int32, Object[])

Writes data to a sequential file. Data written with Write is usually read from a file by using Input.

WriteLine(Int32, Object[])

Writes data to a sequential file. Data written with Write is usually read from a file by using Input.

Applies to

See also