Open In App

ASP Drive Property

The ASP Drive Property is used to return the drive letter name where the specified file or folder resides.

Syntax:



The below examples demonstrate the ASP Drive property:

Example 1: The below code demonstrates the ASP File.Drive Property.




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




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

Article Tags :