Chinaunix首页 | 论坛 | 博客
  • 博客访问: 845233
  • 博文数量: 245
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 2801
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-15 10:31
文章分类

全部博文(245)

文章存档

2011年(1)

2010年(43)

2009年(102)

2008年(99)

我的朋友

分类:

2009-03-17 20:39:28

Attributes 属性

设置或返回文件或文件夹的属性。可读写或只读(与属性有关)。

object.Attributes [= newattributes]

参数

object

必选项。应为 FileFolder 对象的名称。

newattributes

可选项。如果指定此参数,则 newattributes 为指定的 object 的属性的新值。

设置

newattributes 参数可为下列设置之一或下列设置的合理组合:

常数 描述
Normal 0 普通文件。没有设置任何属性。
ReadOnly 1 只读文件。可读写。
Hidden 2 隐藏文件。可读写。
System 4 系统文件。可读写。
Directory 16 文件夹或目录。只读。
Archive 32 上次备份后已更改的文件。可读写。
Alias 1024 链接或快捷方式。只读。
Compressed 2048 压缩文件。只读。

说明

忽略对只读属性(别名,压缩或目录)所作的改变.

当设置属性时,应首先阅读当前属性,然后按要求改变个别属性,最后反写属性.

以下代码举例说明如何使用 Attributes 属性:

Function ToggleArchiveBit(filespec)
  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.GetFile(filespec)
  If f.attributes and 32 Then
    f.attributes = f.attributes - 32
    ToggleArchiveBit = "清空归档位。"
  Else
    f.attributes = f.attributes + 32
    ToggleArchiveBit = "设置归档位。"
  End If
End Function
阅读(568) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~