ASP執行個體教程:Drive對象

來源:互聯網
上載者:User
取得指定磁碟機的可用空間數:本例示範如何首先建立一個FileSystemObject對象,然後使用AvailableSpace屬性來獲得指定磁碟機的可用空間。

取得指定磁碟機的可用空間數:本例示範如何首先建立一個FileSystemObject對象,然後使用AvailableSpace屬性來獲得指定磁碟機的可用空間。取得指定磁碟機的剩餘空間容量:本例示範如何使用FreeSpace空間屬性來取得指定磁碟機的剩餘空間。取得指定磁碟機的總容量:本例演


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.webjx.com)收集整理或者原創內容,轉載請註明出處!

本執行個體代碼如下:

<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.webjx.com)整理髮布!轉載請註明出處,謝謝!

本執行個體代碼如下:

<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.webjx.com)發布!轉載和採集的話請不要去掉!謝謝。

本執行個體代碼如下:

<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>
 



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.