Kod: Tümünü seç
type FilesArray=array[1..1000] of string;
Kod: Tümünü seç
type
TSearchRec = record
Time : Integer;
Size : Integer;
Attr : Integer;
Name : TFileName;
ExcludeAttr : Integer;
FindHandle : THandle;
FindData : TWin32FindData;
end;
Time – En son değiştirilme tarihi
Size – Dosyanın boyutu
Attr – Dosya özellikleri
Name – Dosyanın adı
Klasördeki bütün dosyaları algılama uygulaması:
Kod: Tümünü seç
function GetFiles(dirpath:string; var nrfiles:integer):FilesArray;
var
searchResult : TSearchRec;
allfiles: FilesArray;
begin
nrfiles:=0;
if FindFirst(dirpath+'*.*', faAnyFile, searchResult) = 0 then
begin
repeat
if (searchresult.name<>'.') and (searchresult.name<>'..') then
begin
inc(nrfiles);
allfiles[nrfiles]:=searchresult.name;
end;
until FindNext(searchResult) <> 0;
FindClose(searchResult);//free the memory
GetFiles:=allfiles;
end;
end;
Kod: Tümünü seç
procedure UploadFiles(host: string; username: string; password: string);
var
files:FilesArray;
j,nrfiles:integer;
idftp1:TIdFtp;
begin
{ ftp server’a bağlan}
idftp1.Host:=host;
idftp1.Username:=username;
idftp1.Password:=password;
idftp1.Connect;
//go in which directory you need with ChangeDir command
idftp1.ChangeDir('www');
{Yoldaki bütün dosyaları algıla}
files:=Getfiles(ExtractFilePath(application.exename)+'mydir\',nrfiles);
{ ftp server’a klasördeki bütün dosyaları yolla}
for j:=1 to nrfiles do
begin
idftp1.put(ExtractFilePath(application.exename) + 'mydir\' + files[j], files[j]);
except
On E:Exception do
begin
end;
end;
end;
{ftp server’dan bağlantıyı kes}
idftp1.Quit;
end;