FileAttr Function
Devolve o modo de acceso ou o número de acceso do ficheiro aberto coa instrución Open. O número de acceso do ficheiro depende do sistema operativo (OSH = Operating System Handle).
Se usa un sistema operativo de 32 bits, non pode usar a función FileAttr para determinar o número de acceso do ficheiro.
See also: Open
Sintaxe:
FileAttr (NúmeroFicheiro As Integer, Atributo As Integer)
Valor de retorno:
Enteiro
Parámetros:
FileNumber: The number of the file that was opened with the Open statement.
Attribute: Integer expression that indicates the type of file information that you want to return. The following values are possible:
1: A función FileAttr indica o modo de acceso do ficheiro.
2: A función FileAttr devolve o número de acceso do ficheiro do sistema operativo.
Se especifica un atributo de parámetro co valor 1, aplícanse os seguintes valores de retorno:
1 - INPUT (ficheiro aberto para entrada)
2 - OUTPUT (ficheiro aberto para saída)
4 - RANDOM (ficheiro aberto para acceso aleatorio)
8 - APPEND (ficheiro aberto para anexionar)
32 - BINARY (ficheiro aberto en modo binario).
Exemplo:
Sub ExampleFileAttr
Dim iNumber As Integer
Dim sLine As String
Dim aFile As String
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Output As #iNumber
Print #iNumber, "This is a line of text"
MsgBox FileAttr(#iNumero, 1 ),0,"Modo de acceso"
MsgBox FileAttr(#iNumero, 2 ),0,"Atributo de ficheiro"
Close #iNumber
End Sub