Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 30th, 2005, 03:46 AM
freeasphelp's Avatar
freeasphelp freeasphelp is offline
Beyond The Impossible
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2003
Location: Shawnee Mission, KS, USA
Posts: 921 freeasphelp User rank is Corporal (100 - 500 Reputation Level)freeasphelp User rank is Corporal (100 - 500 Reputation Level)freeasphelp User rank is Corporal (100 - 500 Reputation Level)freeasphelp User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 25 m 9 sec
Reputation Power: 6
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"))
%>
Example Returns: 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"))
%>
Example Returns: C:\WINDOWS\
__________________
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > ASP Classic: GetFileName(Path) Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway