在ASP中如何将代码生成的文件设为只读
发表于:2007-06-30来源:作者:点击数:
标签:
Attributes Propertybr Sets or returns the attributes of files or folders. Read/write or read-only, depending on the attribute.br br object.Attributes [= newattributes] br br Argumentsbr objectbr br Required. Always the name of a File or Fol
Attributes Property<br>
Sets or returns the attributes of files or folders. Read/write or read-only, depending on the attribute.<br>
<br>
object.Attributes [= newattributes] <br>
<br>
Arguments<br>
object<br>
<br>
Required. Always the name of a File or Folder object.<br>
<br>
newattributes<br>
<br>
Optional. If provided, newattributes is the new value for the attributes of the specified object.<br>
<br>
Settings<br>
The newattributes argument can have any of the following values or any logical combination of the following values:<br>
<br>
Const
ant Value Description <br>
Normal 0 Normal file. No attributes are set. <br>
ReadOnly 1 Read-only file. Attribute is read/write. <br>
Hidden 2 Hidden file. Attribute is read/write. <br>
System 4 System file. Attribute is read/write. <br>
Directory 16 Folder or directory. Attribute is read-only. <br>
Archive 32 File has changed since last backup. Attribute is read/write. <br>
Alias 1024 Link or shortcut. Attribute is read-only. <br>
Compressed 2048 Compressed file. Attribute is read-only. <br>
<br>
<br>
Remarks<br>
Attempts to change any of the read-only attributes (Alias, Compressed, or Directory) are ignored. <br>
<br>
When setting attributes, it is generally a good idea to first read the current attributes, then change the individual attributes as desired, and finally write the attributes back.<br>
<br>
The following code illustrates the use of the Attributes property with a file: <br>
<br>
Function ToggleArchiveBit(filespec)<br>
Dim fso, f<br>
Set fso = CreateObject("Scripting.FileSystemObject")<br>
Set f = fso.GetFile(filespec)<br>
If f.attributes and 32 Then<br>
f.attributes = f.attributes - 32<br>
ToggleArchiveBit = "Archive bit is cleared."<br>
Else<br>
f.attributes = f.attributes + 32<br>
ToggleArchiveBit = "Archive bit is set."<br>
End If<br>
End Function<br>
原文转自:http://www.ltesting.net