FileAttr Function

FileAttr palauttaa Open-lauseella avatun tiedoston saantitavan tai tiedoston saantinumeron. Tiedoston saantinumero on käyttöjärjestelmäriippuvainen (OSH).

Huomautus-kuvake

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


Katso myös: Open

Syntaksi:


  FileAttr (Channel As Integer, Attributes As Integer)

Paluuarvo:

Integer-tyypin kokonaisluku

Parametrit:

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.

Jos attribuutti1-parametrilla on arvo 1, seuraavat palautusarvot ovat käytössä:

1 - INPUT (tiedosto avattu kirjoittamiselle)

2 - OUTPUT (tiedosto avattu lukemiselle)

4 - RANDOM (tiedosto avattu suorasaantia varten)

8 - APPEND (tiedosto avattu jatkamista varten)

32 - BINARY (tiedosto avattu binääritilaan).

Virhekoodit:

5 Virheellinen proseduurikutsu

52 Virheellinen tiedoston nimi tai numero

Esimerkki:


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, "Tämä on tekstirivi."
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

Please support us!