2,drv.asp
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set drv=fso.GetDrive(fso.GetDriveName("d:"))
%>
该盘的空间大小:<%=drv.TotalSize%><br>
该盘的剩余空间大小:<%=drv.FreeSpace%>
以上只是提取的D盘驱动器的信息,来个通用的函数,继续分别测试自己的驱动吧。
3,drvinfo.asp
<%
Function ShowDriveInfo(drvPath)
Dim fso, drv, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set drv = fso.GetDrive(fso.GetDriveName(drvPath))
s = "驱动盘" & drv & "的卷标是:"
s = s & drv.VolumeName & "<br>"
s = s & "总计空间:" & drv.TotalSize & "<br>"
s = s & "剩余空间:" & drv.FreeSpace & "<br>"
s = s & "文件类型:" & drv.DriveType & "<br>"
s = s & "文件系统:" & drv.FileSystem
Response.Write s
End Function
%>
<%
on error resume next
whatpath=request.form("path")
if whatpath<>"" then
ShowDriveInfo(whatpath)
end if%>
<form action="drvinfo.asp" method="post">
<input name="path">
<input type="submit">
</form>
其中的drv.TotalSize和drv.FreeSpace返回的是字节数,我们可以用FormatNumber()函数处理下。比如FormatNumber(Drive.TotalSize/1024,0)得到一眼就知磁盘多少G的值。 还有一个文件类型:drv.DriveType最多的时候是显示数值“2”,其实“2”就表示的“硬盘驱动器”,“1”表示“软盘驱动器”,“4”表示“光盘驱动器”…… 下面就用一个程序遍历显示自己机器上所有驱动器的信息 4,showall.asp <% Function tran(Driver) Select Case Driver Case 0: tran="设备无法识别" Case 1: tran="软盘驱动器" Case 2: tran="硬盘驱动器" Case 3: tran="网络硬盘驱动器" Case 4: tran="光盘驱动器" Case 5: tran="RAM虚拟磁盘" End Select End Function set fso=Server.CreateObject("Scripting.FileSystemObject") %> <table border=1 width="100%"> <tr> <td>盘符</td> <td>类型</td> <td>卷标</td> <td>总计大小</td> <td>可用空间</td> <td>文件系统</td> <td>序列号</td> <td>是否可用</td> <td>路径</td> </tr> <% on error resume next For each drv in fso.Drives Response.Write "<tr>" Response.Write "<td>" & drv.DriveLetter & "</td>" Response.write "<td>" & tran(drv.DriveType) & "</td>" Response.write "<td>" & drv.VolumeName & "</td>" Response.write "<td>" & FormatNumber(drv.TotalSize / 1024, 0)& "</td>" Response.write "<td>" & FormatNumber(drv.Availablespace / 1024, 0) & "</td>" Response.write "<td>" & drv.FileSystem & "</td>" Response.write "<td>" & drv.SerialNumber & "</td>" Response.write "<td>" & drv.IsReady & "</td>" Response.write "<td>" & drv.Path & "</td>" Response.Write "</tr>" Next set fs=nothing %> </table> www.cnbruce.com/code/showall.asp 恩,是不是很神气?那你可以对自己的机器调试,然后上传到自己的空间去调试,你会发现服务商会你进行了些设置:)当然更神的还在后面面,比如对文件夹,对文件的操作(包括添加、修改和删除)。ps:你对驱动器是不能轻易添加删除的:)作者: √我爱你 时间: 2010-1-17 02:55
又找一个