?
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
Drive 對象用于返回關于本地磁盤驅(qū)動器或者網(wǎng)絡共享驅(qū)動器的信息。
Drive 對象用于返回關于本地磁盤驅(qū)動器或者網(wǎng)絡共享驅(qū)動器的信息。Drive 對象可以返回有關驅(qū)動器的文件系統(tǒng)類型、剩余容量、序列號、卷標名等信息。
注釋:您無法通過 Drive 對象返回有關驅(qū)動器內(nèi)容的信息。要達到這個目的,請使用 Folder 對象。
如需操作 Drive 對象的相關屬性,您需要通過 FileSystemObject 對象來創(chuàng)建 Drive 對象的實例。首先,創(chuàng)建一個 FileSystemObject 對象,然后通過 FileSystemObject 對象的 GetDrive 方法或者 Drives 屬性來實例化 Drive 對象。
Drive 對象的屬性描述如下:
屬性 | 描述 |
---|---|
AvailableSpace | 向用戶返回在指定的驅(qū)動器或網(wǎng)絡共享驅(qū)動器上的可用空間容量。 |
DriveLetter | 返回識別本地驅(qū)動器或網(wǎng)絡共享驅(qū)動器的大寫字母。 |
DriveType | 返回指定驅(qū)動器的類型。 |
FileSystem | 返回指定驅(qū)動器所使用的文件系統(tǒng)。 |
FreeSpace | 向用戶返回在指定的驅(qū)動器或網(wǎng)絡共享驅(qū)動器上的剩余空間容量。 |
IsReady | 如果指定驅(qū)動器已就緒,則返回 true。否則返回 false。 |
Path | 返回其后有一個冒號的大寫字母,用來指示指定驅(qū)動器的路徑名。 |
RootFolder | 返回一個文件夾對象,該文件夾代表指定驅(qū)動器的根文件夾。 |
SerialNumber | 返回指定驅(qū)動器的序列號。 |
ShareName | 返回指定驅(qū)動器的網(wǎng)絡共享名。 |
TotalSize | 返回指定的驅(qū)動器或網(wǎng)絡共享驅(qū)動器的總容量。 |
VolumeName | 設置或者返回指定驅(qū)動器的卷標名。 |
取得指定驅(qū)動器的總容量
本例演示如何使用 TotalSize 屬性來獲得指定驅(qū)動器的總容量。
<!DOCTYPE?html> <html> <body> <% Dim?fs,d,n Set?fs=Server.CreateObject("Scripting.FileSystemObject") Set?d=fs.GetDrive("c:") n?=?"Drive:?"?&?d n?=?n?&?"<br>Total?size?in?bytes:?"?&?d.TotalSize Response.Write(n) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的可用空間數(shù)
本例演示如何首先創(chuàng)建一個 FileSystemObject 對象,然后使用 AvailableSpace 屬性來獲得指定驅(qū)動器的可用空間。
<!DOCTYPE?html> <html> <body> <% Dim?fs,?d,?n Set?fs=Server.CreateObject("Scripting.FileSystemObject") Set?d=fs.GetDrive("c:") n?=?"Drive:?"?&?d n?=?n?&?"<br>Available?Space?in?bytes:?"?&?d.AvailableSpace Response.Write(n) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的剩余空間容量
本例演示如何使用 FreeSpace 空間屬性來取得指定驅(qū)動器的剩余空間。
<!DOCTYPE?html> <html> <body> <% Dim?fs,?d,?n Set?fs=Server.CreateObject("Scripting.FileSystemObject") Set?d=fs.GetDrive("c:") n?=?"Drive:?"?&?d n?=?n?&?"<br>Free?Space?in?bytes:?"?&?d.FreeSpace Response.Write(n) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的驅(qū)動器字母
本例演示如何使用 DriveLetter 屬性來獲得指定驅(qū)動器的驅(qū)動器字母。
<!DOCTYPE?html> <html> <body> <% dim?fs,?d,?n set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?drive?letter?is:?"?&?d.driveletter) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的驅(qū)動器類型
本例演示如何使用 DriveType 屬性來獲得指定驅(qū)動器的驅(qū)動器類型。
<!DOCTYPE?html> <html> <body> <% dim?fs,?d,?n set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?drive?type?is:?"?&?d.DriveType) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的文件系統(tǒng)信息
本例演示如何使用 FileSystem 來取得指定驅(qū)動器的文件系統(tǒng)信息。
<!DOCTYPE?html> <html> <body> <% dim?fs,?d,?n set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?file?system?is:?"?&?d.FileSystem) set?d=nothing set?fs=nothing %> </body> </html>
驅(qū)動器是否已就緒?
本例演示如何使用 IsReady 屬性來檢查指定的驅(qū)動器是否已就緒。
<!DOCTYPE?html> <html> <body> <% dim?fs,d,n set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") n?=?"The?"?&?d.DriveLetter if?d.IsReady=true?then? ????n?=?n?&?"?drive?is?ready." else ????n?=?n?&?"?drive?is?not?ready." end?if? Response.Write(n) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的路徑
本例演示如何使用 Path 屬性來取得指定驅(qū)動器的路徑。
<!DOCTYPE?html> <html> <body> <% dim?fs,d set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?path?is?"?&?d.Path) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的根文件夾
本例演示如何使用 RootFolder 屬性來取得指定驅(qū)動器的根文件夾。
<!DOCTYPE?html> <html> <body> <% dim?fs,d set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?rootfolder?is?"?&?d.RootFolder) set?d=nothing set?fs=nothing %> </body> </html>
取得指定驅(qū)動器的序列號
本例演示如何使用 Serialnumber 屬性來取得指定驅(qū)動器的序列號。
<!DOCTYPE?html> <html> <body> <% dim?fs,d set?fs=Server.CreateObject("Scripting.FileSystemObject") set?d=fs.GetDrive("c:") Response.Write("The?serialnumber?is?"?&?d.SerialNumber) set?d=nothing set?fs=nothing %> </body> </html>