How to set code-generated files to read-only in ASP

Source: Internet
Author: User
Attributes Property
Sets or returns the attributes of files or folders. Read/write or Read-only, depending on the attribute.

Object. Attributes [= Newattributes]

Arguments
Object

Required. Always the name of a File or Folder object.

Newattributes

Optional. If provided, Newattributes is the new value for the attributes of the specified object.

Settings
The Newattributes argument can have any of the following values or any logical combination of the following values:

Constant Value Description
Normal 0 normal file. No attributes are set.
ReadOnly 1 read-only file. Attribute is read/write.
Hidden 2 Hidden file. Attribute is read/write.
System 4 System file. Attribute is read/write.
Directory Folder or directory. Attribute is read-only.
Archive File has changed since last backup. Attribute is read/write.
Alias 1024 Link or shortcut. Attribute is read-only.
Compressed 2048 compressed file. Attribute is read-only.


Remarks
Attempts to the Read-only attributes (Alias, compressed, or Directory) are ignored.

When setting attributes, it's generally a good idea to the ' The current attributes ', then change the individual attr Ibutes as desired, and finally write the attributes back.

The following code illustrates the use of the Attributes property with a file:

Function Togglearchivebit (filespec)
Dim FSO, F
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f = fso. GetFile (filespec)
If F.attributes and Then
F.attributes = f.attributes-32
Togglearchivebit = "Archive bit is cleared."
Else
F.attributes = f.attributes + 32
Togglearchivebit = "Archive bit is set."
End If
End Function



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.