| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
ASP Classic: File Name Functions
Here are two quick functions that can give you the File Name of a Path, in this case C:\WINDOWS\notepad.exe or remove the file name and just give you the root path.
Function: GetFileName Input a String (Path) Returns a String (File Name) Example: Code:
<%
Function GetFileName(Path)
Path = Replace(Path, "/", "\")
If (Len(Path) > 0) AND (InStrRev(Path, "\") <> Len(Path)) Then
GetFileName = Right(Path, (InStrRev(Path, "\")))
Else
Exit Function
End If
End Function
Response.Write(GetFileName("C:\WINDOWS\notepad.exe"))
%>
Function: StripFileName Input a String (Path) Returns a String (Path) Example: Code:
<%
Function StripFileName(Path)
Path = Replace(Path, "/", "\")
If (Len(Path) > 0) AND (InStrRev(Path, "\") <> Len(Path)) Then
StripFileName = Left(Path, (InStrRev(Path, "\")))
Else
Exit Function
End If
End Function
Response.Write(StripFileName("C:\WINDOWS\notepad.exe"))
%>
__________________
John Shepard Beyond The Impossible ----------------------------- Has a post helped you? Please show your apprecitation by clicking the image in the right upper corner.Posting code? Put your code between [code] and [/code] tags. X-Login and X-Send Last edited by freeasphelp : November 30th, 2005 at 04:00 AM. |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > ASP Classic: GetFileName(Path) Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|