📜  ASP 路径属性

📅  最后修改于: 2022-05-13 01:56:43.815000             🧑  作者: Mango

ASP 路径属性

ASP 路径属性用于获取系统上指定文件、文件夹或驱动器的完整路径。

句法:

  • 对于文件对象

    FileObject.Path
  • 对于文件夹对象:

    FolderObject.Path

对于驱动器对象:

DriveObject.Path

下面的示例演示了ASP 路径属性

示例 1:下面的代码说明了 ASP File.Path 属性。

ASP
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Getting the given file
set f=fs.GetFile("d:\GFG\sudo\geeks.asp")
  
'Getting the path of the file
Response.Write("Complete path for the specified file: " & f.Path)
  
set f=nothing
set fs=nothing
%>


ASP
<%
dim fs,fol
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Getting the required folder
set fol=fs.GetFolder("d:\GFG\geeks")
  
'Getting the complete path of the folder
Response.Write("The path of the folder is " & fol.Path)
  
set fol=nothing
set fs=nothing
%>


ASP
<%
dim fs,drive
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Get the required drive
set drive=fs.GetDrive("d:")
  
'Finding the path of the drive
Response.Write("The path of the drive is: " & drive.Path)
  
set drive=nothing
set fs=nothing
%>


输出:

Complete path for the specified file: d:\GFG\sudo\geeks.asp

示例 2:下面的代码说明了 ASP Folder.Path 属性。

ASP

<%
dim fs,fol
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Getting the required folder
set fol=fs.GetFolder("d:\GFG\geeks")
  
'Getting the complete path of the folder
Response.Write("The path of the folder is " & fol.Path)
  
set fol=nothing
set fs=nothing
%>

输出:

The path of the folder is D:\GFG\geeks

示例 3:下面的代码说明了 ASP Drive.Path 属性。

ASP

<%
dim fs,drive
set fs=Server.CreateObject("Scripting.FileSystemObject")
  
'Get the required drive
set drive=fs.GetDrive("d:")
  
'Finding the path of the drive
Response.Write("The path of the drive is: " & drive.Path)
  
set drive=nothing
set fs=nothing
%>

输出:

The path of the drive is: D: