[Delphi] Nazwa pliku z URL

0

Witam

Jak pobrać nazwę pliku z adresu URL. Funkcja ExtractFileName usuwa jedynie "http:" i podaje pozostałą część linka.

0

Musisz zamienić znaki z / na \

function Konwertuj(URL : string) : string;
var
 m : integer;
begin
 for m := 1 to length(URL) do
   begin
    if URL[m] = '/' then URL[m] := '\';
   end;

 Result := ExtractFileName(URL);
end;

// wynikiem będzie: viewtopic.exe
procedure TForm1.Button1Click(Sender: TObject);
begin
 Label1.Caption := Konwertuj('http://4programmers.net/Forum/strona2/viewtopic.exe');
end;
0

albo takie :O
function extracturlfilename(url : string) : string;
var
s : string;
i : integer;
begin
s := url;
for i:=0 to length(url) do
delete(s,1,pos('/',s));
if pos('%20',s) > 0 then
s := stringreplace(s,'%20',' ',[rfreplaceall,rfignorecase]);
result := s;
end;

1 użytkowników online, w tym zalogowanych: 0, gości: 1