C
cjsam
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
VAR
FTPC: TIdFTP;
一个函数如下;是网上一个人写的,我改了点点,大家帮我看看,是不是本身都有问题,我找不出来了,有时候能清空,有时候不行,不行的时候大部分是如果目录下的子文件夹多的时候,我实在找不出来有什么问题。谢谢!
procedure FTP_DeleteAllFiles(RemoteDir: string);
label Files;
var
i,DirCount : integer;
Temp,temp1 : string;
begin
FTPC.ChangeDir(RemoteDir);
if Pos(RemoteDir,FTPC.RetrieveCurrentDir) = 0 then Exit;
Files :
FTPC.List(nil);
DirCount := FTPC.DirectoryListing.Count ;
while DirCount = 0 do
begin
Temp := FTPC.RetrieveCurrentDir;
FTPC.ChangeDirUp;
temp1:=FTPC.RetrieveCurrentDir;
FTPC.RemoveDir(Temp);
FTPC.List(nil);
DirCount := FTPC.DirectoryListing.Count ;
for i := 0 to DirCount - 1 do
if FTPC.DirectoryListing.FileName = RemoteDir then Exit;
end;
for i := 0 to DirCount - 1 do
begin
if Pos(RemoteDir,FTPC.RetrieveCurrentDir) = 0 then Break ;
if FTPC.DirectoryListing.ItemType = ditDirectory then
begin
FTP_DeleteAllFiles(FTPC.DirectoryListing.FileName);
end else begin
FTPC.Delete(FTPC.DirectoryListing.FileName);
goto Files ;
end;
end;
end;
VAR
FTPC: TIdFTP;
一个函数如下;是网上一个人写的,我改了点点,大家帮我看看,是不是本身都有问题,我找不出来了,有时候能清空,有时候不行,不行的时候大部分是如果目录下的子文件夹多的时候,我实在找不出来有什么问题。谢谢!
procedure FTP_DeleteAllFiles(RemoteDir: string);
label Files;
var
i,DirCount : integer;
Temp,temp1 : string;
begin
FTPC.ChangeDir(RemoteDir);
if Pos(RemoteDir,FTPC.RetrieveCurrentDir) = 0 then Exit;
Files :
FTPC.List(nil);
DirCount := FTPC.DirectoryListing.Count ;
while DirCount = 0 do
begin
Temp := FTPC.RetrieveCurrentDir;
FTPC.ChangeDirUp;
temp1:=FTPC.RetrieveCurrentDir;
FTPC.RemoveDir(Temp);
FTPC.List(nil);
DirCount := FTPC.DirectoryListing.Count ;
for i := 0 to DirCount - 1 do
if FTPC.DirectoryListing.FileName = RemoteDir then Exit;
end;
for i := 0 to DirCount - 1 do
begin
if Pos(RemoteDir,FTPC.RetrieveCurrentDir) = 0 then Break ;
if FTPC.DirectoryListing.ItemType = ditDirectory then
begin
FTP_DeleteAllFiles(FTPC.DirectoryListing.FileName);
end else begin
FTPC.Delete(FTPC.DirectoryListing.FileName);
goto Files ;
end;
end;
end;