FileAttr Function

Open 문으로 연 파일의 액세스 모드 또는 파일 액세스 번호를 표시합니다. 파일 액세스 번호는 운영 체제에 따라 달라집니다(OSH = Operating System Handle).

참고 아이콘

If you use a 32-Bit operating system, you cannot use the FileAttr function to determine the file access number.


참고 항목: Open

Syntax:

FileAttr (Channel As Integer, Attributes As Integer)

Return value:

Integer

Parameters:

Channel: The number of the file that was opened with the Open statement.

Attributes: Integer expression that indicates the type of file information that you want to return. The following values are possible:

1: FileAttr indicates the access mode of the file.

2: FileAttr returns the file access number of the operating system.

매개 변수 속성을 1로 지정할 경우 다음의 반환 값이 적용됩니다.

1 - INPUT(입력을 위한 파일 열기)

2 - OUTPUT(출력을 위한 파일 열기)

4 - RANDOM(임의 액세스를 위한 파일 열기)

8 - APPEND(추가를 위한 파일 열기)

32 - BINARY(이진 모드로 파일 열기)

Error codes:

5 잘못된 프로시저 호출입니다.

52 잘못된 파일 이름 또는 번호입니다.

Example:

Sub ExampleFileAttr
    Dim iNumber As Integer
    Dim sLine As String
    Dim aFile As String
    aFile = "C:\Users\ThisUser\data.txt"
    iNumber = Freefile
    Open aFile For Output As #iNumber
    Print #iNumber, "This is a line of text"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

Please support us!