Table Members of the File System Object

Member Description

ChDir Changes the current directory.

ChDrive Changes the current drive.

CurDir Returns the current directory path.

Dir Returns the name of a file, directory, or folder that matches a pattern, file attribute, or the volume label of a drive.

EOF End of file.

FileAttr The mode used to open a file with the Open statement.

FileCopy Copies a file from a source path to a destination path.

FileDateTime Returns the date and time that a file was created or last modified.

FileLen Returns the length of a file in bytes.

FreeFile Returns an Integer representing the next file number available for use by the Open statement.

GetAttr Returns an Integer representing the attributes of a file or directory.

Kill Deletes a file or files.

Loc Specifies the current read/write position within an open file.

LOF Returns a Long integer specifying the length of an open file in bytes.

MkDir Creates a new directory.

Reset Closes all disk files opened using the Open statement.

RmDir Deletes an empty directory.

Seek Returns a Long integer specifying the current read/write position within an open file.

SetAttr Sets attribute information for a file.

These methods are primarily designed to be used with the Open statement, but you may also find them useful with the other objects and methods discussed in this chapter.

Example

ChDir "C:\Documents and Settings" or ChDir ". ChDrive "D:" MsgBox CurDir fileName = Dir("C:\test.txt", vbNormal) EOF(fileNum)

Mode = FileAttr(fileNum, 1)

FileCopy "C:\TestFile.txt", "D:\TestFile.txt" fileDate = FileDateTime("C:\test.txt") fileSize = FileLen("C:\test.txt") FileNumber = FreeFile myAttr = GetAttr(CurDir)

Kill "C:\test.txt" MyLocation = Loc(1) FileLength = LOF(1) MkDir "TestDir" Reset

RmDir "TestDir" Seek(1)

SetAttr "C:\test.txt", vbReadOnly

Return Value

Outputs the current directory path in a message box.

The file name if it exists. Otherwise an empty string.

A Boolean value indicating whether the end of an opened file (specified with a file number) has been reached.

Returns a Long integer indicating the mode used to open a file (Input, Output, Random, and so on).

For example, 1/23/2004 10:25:14 AM For example, 4 For example, 2

0=Normal, 1=Read-Only, 2=Hidden, 4=System, 16=Directory, 32=Archive

A Long integer

For example, 4

If the file is opened in Random mode it returns the number of the next record, otherwise it returns the current byte position in the file.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment