Re: Strip file from URL
- From: Jamie <jamie_5_not_valid_after_5_Please@xxxxxxxxxxx>
- Date: Sat, 26 Nov 2005 13:05:05 -0800
Ryan Styles wrote:
Hi guys/gals.
I am looking for a method to extract the file name from a URL. For example, http://www.somehost.com/downloads/v1.0/thisprogram.exe
I need to be able to extract "thisprogram.exe" from the URL/I and I have no idea how to do this. I have searched for methods and even tried doing so with pos() and some relevant characters, but all with no success.
So, if anyone has a function/procedure laying around that can do this and you don't mind sharing, I would be eternally grateful.
Using D6 on Windows XP Professional.
Thanks in advance,
-- Ryan
here's a little hack that may work for you.
Function GetUrlEndTrail(Url:String):String;
Var
X:integer;
Begin
Result := '';
X:= length(URL);
While (X <> 0)and(URL[X] <> '/') do dec(X);
If X <> 0 then
Result:= Copy(Url, X+1, Lenght(URL)-X);
End;P.S. it also maybe of interest that some links mite be sending you the %20% in the link which is a way to send spaces or control characters. in the above %20% is a space in HEX notation. just something for you to look for.
-- Real Programmers Do things like this. http://webpages.charter.net/jamie_5
.
- Follow-Ups:
- Re: Strip file from URL
- From: Ryan Styles
- Re: Strip file from URL
- References:
- Strip file from URL
- From: Ryan Styles
- Strip file from URL
- Prev by Date: Re: Strip file from URL
- Next by Date: Identify/validate user
- Previous by thread: Strip file from URL
- Next by thread: Re: Strip file from URL
- Index(es):