ASP Type 属性

定义和用法

Type 属性用于返回指定的文件或文件夹的类型。

语法:

  1. FileObject.Type
  2. FolderObject.Type

针对 File 对象的例子

例子 1

  1. <%
  2. dim fs,f
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set f=fs.GetFile("c:test.txt")
  5. Response.Write("The file test.txt is of type: ")
  6. Response.Write(f.Type)
  7. set f=nothing
  8. set fs=nothing
  9. %>

输出:

  1. The file test.txt is of type: Text Document

例子 2

  1. <%
  2. dim fs,f
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set f=fs.GetFile("c:test.asp")
  5. Response.Write("The file test.asp is of type: ")
  6. Response.Write(f.Type)
  7. set f=nothing
  8. set fs=nothing
  9. %>

输出:

  1. The file test.asp is of type: Active Server Document

针对 Folder 对象的例子

  1. <%
  2. dim fs,fo
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set fo=fs.GetFolder("c:\test")
  5. Response.Write("The folder test is of type: ")
  6. Response.Write(fo.Type)
  7. set fo=nothing
  8. set fs=nothing
  9. %>

输出:

  1. The folder test is of type: File Folder