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
Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 192
Intraweb download file link ? 1 156
Dev Express grid collapse 2 45
CheckListBox usage 3 71
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 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