Función FileAttr

Devuelve el modo de acceso o el número de acceso de un archivo que se abrió con la instrucción Open. El número de acceso de archivo depende del sistema operativo (OSH = manejador de sistema operativo).

Icono de nota

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


Consulte también: Open

Sintaxis:


  FileAttr (Channel As Integer, Attributes As Integer)

Valor de retorno:

Entero

Parámetros:

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 se especifica un atributo de parámetro con un valor de 1, se aplican los valores de retorno siguientes:

1 - INPUT (archivo abierto para entrada)

2 - OUTPUT (archivo abierto para salida)

4 - RANDOM (archivo abierto para acceso aleatorio)

8 - APPEND (archivo abierto para agregar)

32 - BINARY (archivo abierto en modo binario).

Códigos de error:

5 Llamada a procedimiento no válida

52 Nombre de archivo o número incorrectos

Ejemplo:


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, "Este es un renglón de texto"
    MsgBox FileAttr(#iNumber, 1), 0, "Access mode"
    MsgBox FileAttr(#iNumber, 2), 0, "File attribute"
    Close #iNumber
End Sub

¡Necesitamos su ayuda!