Funkce FileAttr

Vrátí přístupový režim souboru nebo přístupové číslo k souboru, který byl otevřen příkazem Open. Přístupové číslo závisí na operačním systému (OSH = ukazatel operačního systému).

Ikona poznámky

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


Viz též: Open

Syntaxe:


  FileAttr (Channel As Integer, Attributes As Integer)

Návratová hodnota:

Celé číslo

Parametry:

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.

Pokud u druhého parametru použijete hodnotu 1, použijí se následující návratové hodnoty:

1 - INPUT (soubor otevřen pro vstup)

2 - OUTPUT (soubor otevřen pro výstup)

4 - RANDOM (soubor otevřen pro náhodný přístup)

8 - APPEND (soubor otevřen pro připojení)

32 - BINARY (soubor otevřen v binárním režimu)

Chybové kódy:

5 Neplatné volání procedury

52 Neplatný název nebo číslo souboru

Příklad:


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, "Toto je řádek textu"
    MsgBox FileAttr(#iNumber, 1 ), 0, "Režim přístupu"
    MsgBox FileAttr(#iNumber, 2 ), 0, "Atribut souboru"
    Close #iNumber
End Sub