ASP实例教程:Drive对象


Drive 对象

注意:本实例教程因为和具体空间的驱动器有关,所以运行结果请自行测试,不再提供运行结果。

取得指定驱动器的可用空间数

本例演示如何首先创建一个FileSystemObject对象,然后使用AvailableSpace属性来获得指定驱动器的可用空间。

本实例代码如下:

<html>
<body>
<%
Dim fs, d, n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "驱动器:" & d
n = n & "<br>以字节计的可用空间:" & d.AvailableSpace
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的剩余空间容量

本例演示如何使用FreeSpace空间属性来取得指定驱动器的剩余空间。

本实例代码如下:

<html>
<body>
<%
Dim fs, d, n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "驱动器:" & d
n = n & "<br />以字节计的剩余空间:" & d.FreeSpace
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的总容量

本例演示如何使用TotalSize属性来获得指定驱动器的总容量。

本文是网页教学(http://www.phpstudy.net)收集整理或者原创内容,转载请注明出处!

本实例代码如下:

<html>
<body>
<%
Dim fs,d,n
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set d=fs.GetDrive("c:")
n = "驱动器:" & d
n = n & "<br>以字节计的总容量:" & d.TotalSize
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的驱动器字母

本例演示如何使用DriveLetter属性来获得指定驱动器的驱动器字母。

本实例代码如下:

<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("驱动器字母是:" & d.driveletter)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的驱动器类型

本例演示如何使用DriveType属性来获得指定驱动器的驱动器类型。

本实例代码如下:

<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("驱动器类型是:" & d.DriveType)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的文件系统信息

本例演示如何使用FileSystem来取得指定驱动器的文件系统类型。

本文由网页教学网(http://www.phpstudy.net)整理发布!转载请注明出处,谢谢!

本实例代码如下:

<html>
<body>
<%
dim fs, d, n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("文件系统是:" & d.FileSystem)
set d=nothing
set fs=nothing
%>
</body>
</html>

驱动器是否已就绪?

本例演示如何使用IsReady属性来检查指定的驱动器是否已就绪。

本实例代码如下:

<html>
<body>
<%
dim fs,d,n
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
n = "此 " & d.DriveLetter
if d.IsReady=true then
    n = n & " 驱动器已就绪。"
else
    n = n & " 驱动器未就绪。"
end if
Response.Write(n)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的路径

本例演示如何使用Path属性来取得指定驱动器的路径。

本实例代码如下:

<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("路径是:" & d.Path)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的根文件夹

本例演示如何使用RootFolder属性来取得指定驱动器的根文件夹。

本实例代码如下:

<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("根文件是:" & d.RootFolder)
set d=nothing
set fs=nothing
%>
</body>
</html>

取得指定驱动器的序列号

本例演示如何使用Serialnumber属性来取得指定驱动器的序列号。

本文由网页教学网(www.phpstudy.net)发布!转载和采集的话请不要去掉!谢谢。

本实例代码如下:

<html>
<body>
<%
dim fs,d
set fs=Server.CreateObject("Scripting.FileSystemObject")
set d=fs.GetDrive("c:")
Response.Write("序列号:" & d.SerialNumber)
set d=nothing
set fs=nothing
%>
</body>
</html>


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3