Fonction FileAttr

Renvoie le mode d'accès ou le numéro d'accès d'un fichier ouvert avec l'instruction Open. Le numéro d'accès du fichier dépend du système d'exploitation (OSH, ou Operating System Handle).

IcĂ´ne Remarque

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


Voir aussi : Open.

Syntaxe :


  FileAttr (Channel As Integer, Attributes As Integer)

Valeur de retour :

Nombre entier

Paramètres :

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.

Un paramètre d'attribut ayant la valeur 1 peut renvoyer les valeurs suivantes :

1 - INPUT (fichier ouvert pour entrée)

2 - OUTPUT (fichier ouvert pour sortie)

4 - RANDOM (fichier ouvert pour accès aléatoire)

8 - APPEND (fichier ouvert pour ajout)

32 - BINARY (fichier ouvert en mode binaire).

Codes d'erreur :

5 appel de procédure incorrect

52 nom ou numéro de fichier incorrect

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, "Ceci est une ligne de texte."
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub