Re: Strip file from URL



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

.