Solved

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

Posted on 2006-06-15
3
360 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now