Cases
| The code is as follows |
Copy Code |
|
<HTML>
<HEAD><TITLE> Get file Property Code </TITLE></HEAD>
<BODY>
<%
' Create a case of a FileSystemObject object
Set myfileobject=server.createobject ("Scripting.FileSystemObject")
' Create a case of a file object
Filename=server.mappath ("./") & "Test.html"
Set myfile=myfileobject.getfile (filename)
%>
<Br> name £ <%=myfile.name%>
<Br> Path: <%=myfile.path%>
<Br> Drive: <%=myfile.drive%>
<Br> File Size: <%=myfile.size%>
<Br> file type: <%=myfile.type%>
<Br> file properties: <%=myfile.attributes%>
<Br> Date Created: <%=myfile.datecreated%>
<Br> last accessed time: <%=ff. Datelastaccessed%>
<Br> Last modified: <%=ff. Datelastmodified%>
</BODY>
</HTML> |
FSO to generate files and set their properties
| The code is as follows |
Copy Code |
|
<%
' Create a case of a FileSystemObject object
Set Myfileobject=server.createobject ("Scripting.FileSystemObject")
' Create a case of a file object
Set Myfile=myfileobject.getfile (Server.MapPath ("1.txt"))
' Set its properties to read-only
Myfile.attributes=1
%> |
Principle
When the FSO creates the file, it returns a TextStream object ...
And the FSO to set the properties of a file or folder. You must get a file or Folder object.
Sir into the document. Then use the getfile to get the file object of this document. And then set its Attributes property value, it's OK.