📅  最后修改于: 2023-12-03 14:59:23.824000             🧑  作者: Mango
ASP 中的 DriveType 属性用于获取指定驱动器的类型。驱动器类型包括硬盘驱动器、CD/DVD-ROM 驱动器、网络驱动器等。
<%
Dim FileSystemObject, Drive
Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
Set Drive = FileSystemObject.GetDrive("C:\")
Response.Write Drive.DriveType
%>
上述代码将获取 C 盘的驱动器类型,并输出到网页上。
| 常数 | 值 | 说明 |
| ---------- | ---- | ---------- |
| Unknown
| 0 | 未知类型 |
| Removable
| 1 | 可移动磁盘 |
| Fixed
| 2 | 本地硬盘 |
| Network
| 3 | 网络驱动器 |
| CDRom
| 4 | CD-ROM 驱动器 |
| RAMDisk
| 5 | RAM 磁盘 |
<%
Dim FileSystemObject, Drive
Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
Set Drive = FileSystemObject.GetDrive("C:\")
Select Case Drive.DriveType
Case 0
Response.Write "未知类型"
Case 1
Response.Write "可移动磁盘"
Case 2
Response.Write "本地硬盘"
Case 3
Response.Write "网络驱动器"
Case 4
Response.Write "CD-ROM 驱动器"
Case 5
Response.Write "RAM 磁盘"
End Select
%>
上述代码将根据 C 盘的驱动器类型,输出相应的类型名称。