Valide sur les plates-formes NetWare, Symbian OS, UNIX, Windows et Windows CE
La fonction SetFileAttributes définit les attributs du fichier ou du répertoire spécifié par le nom de fichier.
Format de la fonction :
SetFileAttributes(filename as String,attr as Integer) as Boolean
Indique le chemin du fichier.
Indique la valeur à définir.
Windows
Valeurs des attributs de fichier sur Windows :
Valeur : 1
Valeur : 2
Valeur : 4
Valeur : 16
Valeur : 32
Valeur : 128
Valeur : 256
Valeur : 2048
Valeur : 4096
Exemple :
Cet exemple répertorie les attributs de AUTOEXEC.BAT et modifie l'indicateur Hidden.
dim attr as integer
dim out as string
attr=GetFileAttributes("C:BAT")
if (attr<>-1) then
out=out+"Attributs : "+chr(9)+"["
if attr and FA_ARCHIVE then out=out+"A"
if attr and FA_SYSTEM then out=out+"S"
if attr and FA_HIDDEN then out=out+"H"
if attr and FA_RDONLY then out=out+"R"
out=out+"]"
MsgBox("Informations sur C:\AUTOEXEC.BAT"+chr(10)+chr(10)+out)
else
MsgBox("C:\AUTOEXEC.BAT est introuvable")
end if
if attr and FA_HIDDEN then
attr = attr - FA_HIDDEN
SetFileAttributes("C:\AUTOEXEC.BAT", attr)
else
attr = attr + FA_HIDDEN
SetFileAttributes("C:\AUTOEXEC.BAT", attr)
End If
end:
|
Copyright © 2014 CA Technologies.
Tous droits réservés.
|
|