Solved

Looking for a Code to download file(s) from FTP server and delete.

Posted on 2006-06-15
3
364 Views
Last Modified: 2007-10-18
Hi Experts

I am looking for a script to work on Windows wich will download file(s) from a server using indy ftp and than delete the file(s) after downloading.

Waiting for a quick response..

Thanks
0
Comment
Question by:royalcyber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16918228
var
  s : TFileStream;
  Host, UserName, Password, FTPFileName, LocalFileName : String;
begin
  IdFTP1.Host := Host;
  IdFTP1.Username := UserName;
  IdFTP1.Password := Password;
  s := TFileStream.Create(LocalFileName, fmOpenWrite);
  IdFTP1.Get(FTPFileName, s);
  IdFTP1.Delete(FTPFileName);
  IdFTP1.Disconnect;
  s.Free;
end;
0
 
LVL 10

Accepted Solution

by:
atul_parmar earned 125 total points
ID: 16918236
var
  s : TFileStream;
  Host, UserName, Password, FTPFileName, LocalFileName : String;
begin
  IdFTP1.Host := Host;
  IdFTP1.Username := UserName;
  IdFTP1.Password := Password;
  s := TFileStream.Create(LocalFileName, fmOpenWrite);
  IdFTP1.Connect; >>>>>>>>>>>> This line was missed
  IdFTP1.Get(FTPFileName, s);
  IdFTP1.Delete(FTPFileName);
  IdFTP1.Disconnect;
  s.Free;
end;
0
 

Author Comment

by:royalcyber
ID: 16966531


Thanks atul, it worked good.

Regards
Azhar
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question