Export (0) Print
Expand All

FileAttr Function

Returns an enumeration representing the file mode for files opened using the FileOpen function.

The My.Computer.FileSystem Object gives you greater productivity and performance in file I/O operations than the FileAttr function. See My.Computer.FileSystem.GetFileInfo Method for more information.

Public Function FileAttr(ByVal FileNumber As Integer) As OpenMode

FileNumber

Required. Integer. Any valid file number.

Exception type

Error number

Condition

IOException

52

FileNumber does not exist.

IOException

54

File mode is invalid.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

The following enumeration values indicate the file access mode:

Value

Mode

1

OpenMode.Input

2

OpenMode.Output

4

OpenMode.Random

8

OpenMode.Append

32

OpenMode.Binary

This function returns an enumeration representing the file mode for files opened using the FileOpen function.

This example uses the FileAttr function to return the file mode of an open file.

Dim mode As OpenMode
FileOpen(1, "c:\TESTFILE.TXT", OpenMode.Input)
mode = FileAttr(1)
MsgBox("The file mode is " & mode.ToString())
FileClose(1)

This function is not supported.

Namespace: Microsoft.VisualBasic

Module: FileSystem

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Community Additions

ADD
Show:
© 2014 Microsoft