ASP GetFileNameMethod
Complete FileSystemObject Object Reference Manual
The GetFileName method returns a string containing the file name or folder name of the last component in the specified path.
Syntax
FileSystemObject.GetFileName(path)
| Parameters | Description |
|---|---|
| path | Required. The path pointing to a specific file or folder. |
Example
Get the file name:
<%
dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.getfilename("c:\test\test.htm")
response.write(p)
set fs=nothing
%>
Output:
test.htm
dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.getfilename("c:\test\test.htm")
response.write(p)
set fs=nothing
%>
Output:
test.htm
Get the folder name:
<%
dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.getfilename("c:\test\")
response.write(p)
set fs=nothing
%>
Output:
test
dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.getfilename("c:\test\")
response.write(p)
set fs=nothing
%>
Output:
test
Complete FileSystemObject Object Reference Manual Other extensions