ASP GetFileName Method

Definition and Usage

The GetFileName method returns a string that contains the file name or folder name of the last component in the specified path.

Syntax:

FileSystemObject.GetFileName(path)
Parameter Description
path Required. The path to a specific file or folder.

Instance

Example 1

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

Example 2

<%
dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
p=fs.getfilename("c:\test\")
response.write(p)
set fs=nothing
%>

Output:

test