Funció FileAttr

Retorna el mode d'accés o el número d'accés de fitxer d'un fitxer que es va obrir amb l'expressió Open. El número d'accés del fitxer depèn del sistema operatiu (OSH = Operating System Handle).

Icona de nota

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


Vegeu també: Obre

Sintaxi:


  FileAttr (Channel As Integer, Attributes As Integer)

Valor de retorn:

Enter

Paràmetres:

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.

Si especifiqueu un atribut de paràmetre amb un valor d'1, s'apliquen els valors de retorn següents:

1 - INPUT (fitxer obert per entrada)

2 - OUTPUT (fitxer obert per sortida)

4 - RANDOM (fitxer obert per accés aleatori)

8 - APPEND (fitxer obert per ser afegit)

32 - BINARY (fitxer obert en mode binari).

Codis d'error

5 La crida al procediment no és vàlida

52 El nom o el número del fitxer és incorrecte

Exemple:


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, "Això és una línia de text"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

Ens cal la vostra ajuda!