The ASP Drive Property is used to return the drive letter name where the specified file or folder resides.
Syntax:
-
For File Object:
FileObject.Drive
-
For Folder Object:
FolderObject.Drive
The below examples demonstrate the ASP Drive property:
Example 1: The below code demonstrates the ASP File.Drive Property.
ASP
<% dim fs,f set fs=Server.CreateObject( "Scripting.FileSystemObject" )
'Getting the given file set f=fs.GetFile( "d:\GFG.txt" )
Response.Write( "File resides on drive: " )
'Getting the drive where the file resides Response.Write(f.Drive) set f=nothing set fs=nothing %> |
Output:
File resides on drive: d:
Example 2: The below code demonstrates the ASP Folder.Drive Property.
ASP
<% dim fs,fol set fs=Server.CreateObject( "Scripting.FileSystemObject" )
'Getting the required folder set fol=fs.GetFolder( "D:\GFG" )
'Getting the drive where the folder is stored Response.Write( "This folder is on drive " & fol.Drive)
'Getting another folder set fol=fs.GetFolder( "F:\Downloads" )
'Getting the drive where the folder is stored Response.Write( "<br> This folder is on drive " & fol.Drive)
set fol=nothing set fs=nothing %> |
Output:
This folder is on drive D: This folder is on drive F: