把分1给我把[
]
function GetFileName(path:string):string;
var
startpos,endpos:integer;
stemp:string;
i,c:integer;
fullname,fpath:string;
function StrSubCount(const Sub,Source: string): integer;
var
Buf : string;
i : integer;
Len : integer;
begin
Result := 0;
Buf:=Source;
i := Pos(Sub, Buf);
Len := Length(Sub);
while i <> 0 do
begin
Inc(Result);
Delete(Buf, 1, i + Len -1);
i:=Pos(Sub,Buf);
end;
end;
function PosEx(const Sub,Source: string; Index: Integer = 1): Integer;
var
I, J, K, L: Integer;
T: string;
begin
Result := 0;
T := Source;
K := 0;
L := Length(Sub);
for I := 1 to Index do begin
J := Pos(Sub, T);
if J <= 0 then Exit;
Delete(T, 1, J + L - 1);
Inc(K, J + L - 1);
end;
Dec(K, L - 1);
Result := K;
end;
begin
result:='';
startpos:=PosEx('/',path,1);
endpos:=PosEx('/',path,StrSubCount('/',path));
fpath:= copy(path, startpos-2,endpos-startpos+3 );
c:=length(path)-endpos;
stemp:=copy(path,endpos+1,c);
for i:=1 to c do
begin
fullname:=fpath+copy(stemp,1,i);
if fileexists(fullname) then
result:=fullname;
end;
end;