idFTP Upload Loop Needed

Hi all,

On my host I've got a bunch of folders with have the same name as filenames stored in my pc.
I need to update these files via idFTP to the server and save them in there own folders one at a time.

The Folder names and filenames match, so for example:

Filename: AAEESS.csv with be uploaded into the AAEESS Folder
                AADDEE.csv with be uploaded into the AADDEE Folder

Etc...

Hope you can help!

Thanks

ST3VO


ST3VOAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
well, you write a function that uploads one of those files and then you call it for every file (you do a findfirst/findnext)

something like this:

procedure tform1.uploadfile(filename:string);
var dir:string;
begin
  dir:=extractfilename(filename);
  while dir[length(dir)]<>'.' do
    delete(dir, length(dir), 1);
  delete(dir, length(dir), 1);
  idftp1.ChangeDir(dir);
  idftp1.put(filename);
  idftp1.ChangeDirUp;
end;

procedure tform1.uploadfrom(dirfrom, dirto:string);
var r:tsearchrec;
begin
  idftp1.ChangeDir(dirto);
  dirfrom:=IncludeTrailingPathDelimiter(dirfrom);
  if findfirst(dirfrom+'*.csv', faanyfile-fadirectory, r)=0 then
    repeat
      uploadfile(dirfrom+r.name);
    until findnext(r)<>0;
end;
0
Question has a verified solution.

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.

All Courses

From novice to tech pro — start learning today.