Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
Procedure UploadFiles(Dir, FTPTargetDir: string);
var
SR : TSearchRec;
begin
// Dir is the Path of the directory you are searching its files
if FindFirst(Dir + '*.*', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
// the file path can be obtained by using Dir+SR.Name so you can upload it or do whatever you want with it
form3.idftp1.Put(Dir + SR.Name, FTPTargetDir + SR.Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;
function CopySubDirStruct(Dir, FTPTargetDir: string): integer; // Dir & FTPTargetDir Should be teminated with \
var
sr: TSearchRec;
n: integer;
begin
n:= 0;
if FindFirst(Dir+'*.*', faDirectory, sr) = 0 then
begin
repeat
if ((sr.Attr and faDirectory)=sr.Attr) and (Pos('.', sr.Name)=0) then
begin
form3.idftp1.MakeDir(FTPTargetDir+sr.Name);
UploadFiles(Dir + SR.Name+'\', FTPTargetDir+SR.Name+'\');
n:= n + CopySubDirStruct(Dir+sr.Name+'\', FTPTargetDir+sr.Name+'\');
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
Result:= n;
end;
function CopyDirStruct(Dir, FTPTargetDir: string): integer; // Dir & FTPTargetDir Should be teminated with \ and /
var
sr: TSearchRec;
n: integer;
begin
n:= 0;
if FindFirst(Dir+'*.*', faDirectory, sr) = 0 then
begin
repeat
if ((sr.Attr and faDirectory)=sr.Attr) and (Pos('.', sr.Name)=0) then
begin
if (FTPTargetDir='') then
form3.idftp1.ChangeDir('/')
else form3.idftp1.ChangeDir(FTPTargetDir);
form3.idftp1.MakeDir(sr.Name);
n:= n + CopySubDirStruct(Dir+sr.Name+'\', FTPTargetDir+sr.Name+'/');
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
Result:= n;
end;
Consider what Geert said.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Open in new window
how do you call this func ?