ASP Drive 属性

定义和用法

Drive 属性可用于返回指定的文件或文件夹所在的驱动器的驱动器字母(驱动器号)。

语法:

  1. FileObject.Drive
  2. FolderObject.Drive

针对 File 对象的例子

  1. <%
  2. dim fs,f
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set f=fs.GetFile("c:\test.txt")
  5. Response.Write("File resides on drive: ")
  6. Response.Write(f.Drive)
  7. set f=nothing
  8. set fs=nothing
  9. %>

输出:

  1. File resides on drive: c:

针对 Folder 对象的例子

  1. <%
  2. dim fs,fo
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set fo=fs.GetFolder("c:\test")
  5. Response.Write("Folder resides on drive: ")
  6. Response.Write(fo.Drive)
  7. set fo=nothing
  8. set fs=nothing
  9. %>

输出:

  1. Folder resides on drive: c: