Property:
File.Attributes
Implemented in version 3.0
object.Attributes [ = newattributes]
This property allows us to get or change the various attributes of a file. The available attribute values are listed below.
|
Name
|
Value
|
Description
|
Read/Write
attribute
|
|
Normal
|
0
|
Normal
file
|
Read/write
|
| ReadOnly |
1
|
Read-only
file
|
Read
only
|
| Hidden |
2
|
Hidden file
|
Read/write
|
| System |
4
|
System file
|
Read/write
|
| Volume |
8
|
Disk drive
volume label |
Read
only
|
| Directory |
16
|
Folder or directory
|
Read-only
|
| Archive |
32
|
File has
changed since last backup
|
Read/write
|
| Alias |
64
|
Link or shortcut
|
Read-only
|
| Compressed |
2048
|
Compressed
file |
Read-only
|
The following code shows how to check if a file is read/write or read-only. As you can see, logical operators are used to get or change the various attributes.
Code:
<% dim filesys, text, readfile
set filesys =
CreateObject("Scripting.FileSystemObject")
Set text =
filesys.CreateTextFile("c:\somefile2.txt")
text.Write "A
simple test to find if this file is writeable."
text.close
set readfile =
filesys.GetFile("c:\somefile2.txt")
If Not readfile.Attributes And 1 Then
Response.Write "The file is Read/Write."
Else
Response.Write "The file is Read-only."
End If
%>
Output:
"The file is Read/Write."
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information
|