delphi 获取一个文件的属性|FileGetAttr 函数
FileGetAttr 函数
FileGetAttr 函数用于获取一个文件的属性设置。函数原型如下:
function FileGetAttr(const FileName: string): Integer;
文件属性及其对应的数值:
·FaReadOnly $00000001 只读文件
·FaHidden $00000002 隐藏文件
·FaSysFile $00000004 系统文件
·FaVolumeID $00000008 卷标志文件
·FaDirectory $00000010 目录文件
·FaArchive $00000020 存档文件
·FaAnyFile $0000003F 所有类型文件
例如使用下面的代码获得文件属性的数值,然后可以根据获得的数值与表10-1 对比,得到文件属性。
var
I:Integer;
begin
if OpenDialog1.Execute then
I:=FileGetAttr(OpenDialog1.FileName);
ShowMessage(IntToStr(I));
end;