Share via


FileSystem Module (Visual Basic)

The FileSystem module contains the procedures used to perform file, directory or folder, and system operations.

The My feature gives you greater productivity and performance in file I/O operations than using the FileSystem module. For more information, see My.Computer.FileSystem Object.

Remarks

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

Members

ChDir

ChDrive

CurDir

Dir

EOF

FileAttr

FileClose

FileCopy

FileDateTime

FileGet

FileGetObject

FileLen

FileOpen

FilePut

FilePutObject

FileWidth

FreeFile

GetAttr

Input

InputString

Kill

LineInput

Loc

Lock

LOF

MkDir

Print

PrintLine

Rename

Reset

RmDir

Seek

SetAttr

SPC

TAB

Unlock

Write

WriteLine

 

 

Example

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

See Also

Reference

Directories and Files Summary

Input and Output Summary

Keywords and Members by Task

Visual Basic Language Keywords

Visual Basic Run-Time Library Members

Keywords Compared in Different Languages