Export (0) Print
Expand All

FileSystem Class

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.

System.Object
  Microsoft.VisualBasic.FileSystem

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

[StandardModuleAttribute]
[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
public sealed class FileSystem

The FileSystem type exposes the following members.

  NameDescription
Public methodStatic memberChDirChanges 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 .
Public methodStatic memberChDrive(Char)Changes the current drive.
Public methodStatic memberChDrive(String)Changes the current drive.
Public methodStatic memberCurDir()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.
Public methodStatic memberCurDir(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.
Public methodStatic memberDir()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 for more information.
Public methodStatic memberDir(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 for more information.
Public methodStatic memberEOFReturns a Boolean value True when the end of a file opened for Random or sequential Input has been reached.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodStatic memberFileAttrReturns 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 for more information.
Public methodStatic memberFileCloseConcludes 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.
Public methodStatic memberFileCopyCopies a file. The FileSystem gives you better productivity and performance in file I/O operations than FileCopy. See CopyFile for more information.
Public methodStatic memberFileDateTimeReturns 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
Public methodStatic memberFileGet(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
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGet(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.
Public methodStatic memberFileGetObjectReads 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.
Public methodStatic memberFileLenReturns a Long 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.
Public methodStatic memberFileOpenOpens 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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePut(Object, Object, Object) 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.
Public methodStatic memberFilePut(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..
Public methodStatic memberFilePut(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.
Public methodStatic memberFilePutObjectWrites 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.
Public methodStatic memberFileWidthAssigns an output line width to a file opened by using the FileOpen function.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberFreeFileReturns an Integer value that represents the next file number available for use by the FileOpen function.
Public methodStatic memberGetAttrReturns 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.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberInput(Int32, Boolean)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Byte)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Char)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, DateTime)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Decimal)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Double)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Int16)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Int32)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Int64)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Object)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, Single)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInput(Int32, String)Reads data from an open sequential file and assigns the data to variables.
Public methodStatic memberInputStringReturns 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.
Public methodStatic memberKillDeletes 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 .
Public methodStatic memberLineInputReads a single line from an open sequential file and assigns it to a String variable.
Public methodStatic memberLocReturns a Long value that specifies the current read/write position in an open file.
Public methodStatic memberLock(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.
Public methodStatic memberLock(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.
Public methodStatic memberLock(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.
Public methodStatic memberLOFReturns a Long representing 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.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberMkDirCreates a new directory. The My feature gives you better productivity and performance in file I/O operations than MkDir. For more information, see CreateDirectory.
Public methodStatic memberPrintWrites display-formatted data to a sequential file.
Public methodStatic memberPrintLineWrites display-formatted data to a sequential file.
Public methodStatic memberRenameRenames 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.
Public methodStatic memberResetCloses 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.
Public methodStatic memberRmDirRemoves an existing directory. The My feature gives you better productivity and performance in file I/O operations than RmDir. For more information, see DeleteDirectory.
Public methodStatic memberSeek(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.
Public methodStatic memberSeek(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.
Public methodStatic memberSetAttrSets 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.
Public methodStatic memberSPCUsed with the Print or PrintLine function to position output.
Public methodStatic memberTAB()Used with the Print or PrintLine functions to position output.
Public methodStatic memberTAB(Int16)Used with the Print or PrintLine functions to position output.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodStatic memberUnlock(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.
Public methodStatic memberUnlock(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.
Public methodStatic memberUnlock(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.
Public methodStatic memberWriteWrites data to a sequential file. Data written with Write is usually read from a file by using Input.
Public methodStatic memberWriteLineWrites data to a sequential file. Data written with Write is usually read from a file by using Input.
Top

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

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Resources. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

Community Additions

ADD
Show:
© 2014 Microsoft