View Full Version : Return Path


Surjer
01-03-2002, 06:14 AM
Is there anyway to strip a "path" of everything except the filename?

C:\12mc\1.bmp

will return

1.bmp

Never mind ----

Dir ("C:\12mc\1.bmp")


[This message has been edited by Surjer (edited 01-03-2002).]

raindrop3
01-03-2002, 07:03 AM
Hello,

I run into the same problem, and someone send me a great module. Here it comes:

Public Function getfilename(pathname As Variant)
Dim myloop As Integer
Dim kees
For myloop = Len(pathname) To 1 Step -1
getfilename = getfilename & Mid(pathname, myloop, 1)

Next myloop
'use this in the debug window to get the filename: ?Right(pathname, (InStr(getfilename(pathname), "\") - 1))
'Example: ?Right("c:\test\kjdf\1234.jpg", (InStr(getfilename("c:\test\kjdf\1234.jpg"), "\") - 1))
End Function

Hope this helps.

Greetings,

Albert

[This message has been edited by raindrop3 (edited 01-07-2002).]