呵呵给分吧我刚写了一个东西把函数给你,不过我的东西有点乱,你看看上面的函数就知道了
function FindFiles(ftp:HINTERNET;searchfile:string;listvw:TListView;flist:Tstrings;total:Longint):boolean;//
var
FindData : TWin32FindData;
FindHandle : HInternet;
dirlist:Tstringlist;//文件夹列表
i:integer;
Found:Boolean;
Item: TListItem;
begin
Found:=false;
FindHandle := FtpFindFirstFile(ftp,pchar(searchfile), FindData, 0, 0);
if FindHandle = nil then
begin
Exit;
end;
dirlist:=Tstringlist.Create;
if IsValidDir(FindData) then
dirlist.Add(FindData.cFileName)
else
if (FindData.dwFileAttributes=128) then
if flist.IndexOf(searchfile)=-1 then begin
flist.Add(searchfile);
Item := listvw.Items.Add;
item.ImageIndex:=0;
item.Caption:=string(FindData.CFileName);
Item.SubItems.Add(format('%8.1f',[FindData.nFileSizeLow/1024])+'KB');
total:=total+FindData.nFileSizeLow;//总文件大小
end;
while InternetFindnextFile(FindHandle,@FindData) do begin
if IsValidDir(FindData) then
dirlist.Add(FindData.cFileName)
else
if (string(FindData.cFileName)<>'..') then begin
if flist.IndexOf(searchfile+'/'+string(FindData.CFileName))<>-1 then continue;
flist.Add(searchfile+'/'+string(FindData.CFileName));
Item := listvw.Items.Add;
item.ImageIndex:=0;
item.Caption:=string(FindData.CFileName);
Item.SubItems.Add(format('%8.1f',[FindData.nFileSizeLow/1024])+'KB');
total:=total+FindData.nFileSizeLow;//总文件大小
mytotalsize:=total;
end;
end;
InternetCloseHandle(Findhandle);
found:=true;
for i:=0 to dirlist.Count-1 do
found:=FindFiles(ftp,searchfile+'/'+dirlist.Strings,listvw,flist,total) or found;
dirlist.Free;
end;