Latest web development tutorials
 

ASP GetFileName Method


< Complete FileSystemObject Object Reference

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

Syntax

FileSystemObject.GetFileName(path)

Parameter Description
path Required. The path to a specific file or folder

Examples

Get a filename:

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

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