ASP GetFileNameMethod


FileSystemObject 对象参考手册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

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


FileSystemObject 对象参考手册Complete FileSystemObject Object Reference Manual Other extensions