July 2000
Intermediate to advanced
492 pages
14h 53m
English
Drive (File Object, Folder Object) —
Obj
.Drive
Returns a Drive with which the File or Folder object is associated. This property is read-only.
None
<%
' Dimension local variables.
Dim fsoObject ' FileSystemObject
Dim filObject ' File Object
Dim objDrive ' Drive name
' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
"Scripting.FileSystemObject")
' Using the GetFile method of fsoObject, initialize
' a File object.
Set filObject = fsoObject.GetFile("PublicDocs.txt")
' Retrieve the drive name with which the File object
' is associated.
Set objDrive = filObject.Drive
' Note that this drive is actually the current drive
' in this case.
. . . [additional code]
%>The Drive property can represent either a physical, local, or mapped drive or a network share.
Because the Drive object's default property is Path, you can assign the drive name to a string as follows:
strDrive = filObject.Drive
This is really a shorthand version of:
strDrive = filObject.Drive.Path
If you wish to manipulate the Drive object, though, you must use the
Set statement to assign the reference to an object
variable. For example:
Set objDrive = filObject.Drive
Read now
Unlock full access