Sub ShowDriveInfo(drvPath) Dim fso, drv, s Set fso = CreateObject("Scripting.FileSystemObject") Set drv = fso.GetDrive(fso.GetDriveName(drvPath)) s = "Drive " & UCase(drvPath) & " - " s = s & drv.VolumeName & "<br>" s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0) s = s & " Kb" & "<br>" s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0) s = s & " Kb" & "<br>" Response.Write s End Sub
下面的代码说明在 JScript 中实现同样的功能: function ShowDriveInfo1(drvPath) { var fso, drv, s =""; fso = new ActiveXObject("Scripting.FileSystemObject"); drv = fso.GetDrive(fso.GetDriveName(drvPath)); s += "Drive " + drvPath.toUpperCase()+ " - "; s += drv.VolumeName + "<br>"; s += "Total Space: " + drv.TotalSize / 1024; s += " Kb" + "<br>"; s += "Free Space: " + drv.FreeSpace / 1024; s += " Kb" + "<br>"; Response.Write(s); }