欢迎光临
我们一直在努力

在ASP中如何将代码生成的文件设为只读

建站超值云服务器,限时71元/月

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>
Constant 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>
&nbsp;&nbsp;&nbsp;Dim fso, f<br>
&nbsp;&nbsp;&nbsp;Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)<br>
&nbsp;&nbsp;&nbsp;Set f = fso.GetFile(filespec)<br>
&nbsp;&nbsp;&nbsp;If f.attributes and 32 Then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f.attributes = f.attributes – 32<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ToggleArchiveBit = &quot;Archive bit is cleared.&quot;<br>
&nbsp;&nbsp;&nbsp;Else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f.attributes = f.attributes + 32<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ToggleArchiveBit = &quot;Archive bit is set.&quot;<br>
&nbsp;&nbsp;&nbsp;End If<br>
End Function<br>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在ASP中如何将代码生成的文件设为只读
分享到: 更多 (0)

相关推荐

  • 暂无文章