ورود

View Full Version : چگونه باید از یک اکانت FTp فایلی دانلود کنم؟



majidas2006
یک شنبه 07 فروردین 1390, 03:09 صبح
چگونه باید از یک اکانت FTp فایلی دانلود کنم؟
لطفا آموزش بدید ، من نمی دونم کامپوننت چیه

as13851365
چهارشنبه 10 فروردین 1390, 16:58 عصر
اگه جستجو می گردی توی انجمن پیداش می کردی

من این کدها رو قبلا از انجمن برداشته بودم

{
دانلود فايل از html
}

uses ExtActns, ...

type
TfrMain = class(TForm)
...
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
...

implementation
...

procedure TfrMain.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;

function DoDownload;
begin
with TDownloadURL.Create(self) do
try
URL:='http://z.about.com/6/g/delphi/b/index.xml';
FileName := 'c:\ADPHealines.xml';
OnDownloadProgress := URL_OnDownloadProgress;

ExecuteTarget(nil) ;
finally
Free;
end;
end;

{
Note:
URL property points to Internet
FileName is the local file
}



************************************************** * آپلود از FTP****
procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
localFilename: WideString;
remoteFilename: WideString;

begin
// Import the Chilkat FTP-2 ActiveX control into Delphi and then
// drop an instance of the FTP control onto the form.

// Unlock once at the beginning of your program.
ChilkatFtp21.UnlockComponent('anything for 30-day trial');

ChilkatFtp21.Hostname := 'ftp.chilkatsoft.com';
ChilkatFtp21.Username := '***';
ChilkatFtp21.Password := '***';

// Connect to the server
success := ChilkatFtp21.Connect();
if (success = 1) then
begin
localFilename := 'test.txt';
remoteFilename := 'test.txt';
success := ChilkatFtp21.PutFile(localFilename,remoteFilename) ;
if (success = 0) then
begin
ChilkatFtp21.SaveLastError('ftpUploadError.txt');
ShowMessage('Error in upload. See error log');
end
else
ShowMessage('File uploaded!');
end
else
begin
ChilkatFtp21.SaveLastError('ftpConnectError.txt');
if (ChilkatFtp21.ConnectVerified = 1) then
ShowMessage('Login error. Check your username/password')
else
ShowMessage('Cannot connect to FTP server');
end;

end;

// Put (upload) event callback. This method is called each time
// the percentage-completion updates to a higher value.
procedure TForm1.ChilkatFtp21PutProgress(ASender: TObject;
pctDone: Integer);
begin
// pctDone holds an integer value between 1 and 100.
ProgressBar1.Position := pctDone;
end;

************************************************* دانلود از FTP
// FTP download with progress monitoring
procedure TForm1.Button2Click(Sender: TObject);
var
success: Integer;
localFilename: WideString;
remoteFilename: WideString;

begin
// Import the Chilkat FTP-2 ActiveX control into Delphi and then
// drop an instance of the FTP control onto the form.

// Unlock once at the beginning of your program.
ChilkatFtp21.UnlockComponent('anything for 30-day trial');

ChilkatFtp21.Hostname := 'ftp.chilkatsoft.com';
ChilkatFtp21.Username := '***';
ChilkatFtp21.Password := '***';

// Connect to the server
success := ChilkatFtp21.Connect();
if (success = 1) then
begin
localFilename := 'test2.txt';
remoteFilename := 'test.txt';
// Download test.txt from the FTP server and save it as 'test2.txt'
// on the local system.
success := ChilkatFtp21.GetFile(remoteFilename,localFilename) ;
if (success = 0) then
begin
ChilkatFtp21.SaveLastError('ftpDownloadError.txt') ;
ShowMessage('Error in download. See error log');
end
else
ShowMessage('File downloaded!');
end
else
begin
ChilkatFtp21.SaveLastError('ftpConnectError.txt');
if (ChilkatFtp21.ConnectVerified = 1) then
ShowMessage('Login error. Check your username/password')
else
ShowMessage('Cannot connect to FTP server');
end;

end;

// Get (download) event callback. This method is called each time
// the percentage-completion updates to a higher value.
procedure TForm1.ChilkatFtp21GetProgress(ASender: TObject;
pctDone: Integer);
begin
// pctDone holds an integer value between 1 and 100.
ProgressBar1.Position := pctDone;
end;