18-12-2023, 08:10 PM
السلام عليكم ورحمة الله
هذا جزء من برنامج يقوم تقريبا بنفس الفكرة
ملحوظة البرنامج كله مفتوح المصدر اذا اردت الاطلاع عليه اخبرنى
هذا جزء من برنامج يقوم تقريبا بنفس الفكرة
كود :
procedure TfrMain.CreateOrOpenDirectoryOnFTPServer;
var
I: Integer;
myYear: string;
myMonth: string;
myDate: string;
IsDirectoryExists: Boolean;
begin
IsDirectoryExists := False;
if IdFTP1.Connected then
begin
Memo1.Lines.Add('Connected to ' + IdFTP1.Host);
Memo1.Lines.Add('Start check if the remote folders exists');
myYear := IntToStr(YearOf(Date));
myMonth := FormatSettings.LongMonthNames[MonthOf(Date)];
myDate := FormatDateTime('YYYYMMDD', Date);
IdFTP1.List;
for I := 0 to IdFTP1.DirectoryListing.Count - 1 do
begin
if IdFTP1.DirectoryListing.Items[I].FileName = myYear then
begin
IsDirectoryExists := True;
Break;
end;
end;
if not IsDirectoryExists then
begin
IdFTP1.MakeDir(myYear);
end;
IsDirectoryExists := False;
IdFTP1.ChangeDir(myYear);
IdFTP1.List;
for I := 0 to IdFTP1.DirectoryListing.Count - 1 do
begin
if IdFTP1.DirectoryListing.Items[I].FileName = myMonth then
begin
IsDirectoryExists := True;
Break;
end;
end;
if not IsDirectoryExists then
begin
IdFTP1.MakeDir(myMonth);
end;
IsDirectoryExists := False;
IdFTP1.ChangeDir(myMonth);
IdFTP1.List;
for I := 0 to IdFTP1.DirectoryListing.Count - 1 do
begin
if IdFTP1.DirectoryListing.Items[I].FileName = myDate then
begin
IsDirectoryExists := True;
Break;
end;
end;
if not IsDirectoryExists then
begin
IdFTP1.MakeDir(myDate);
end;
IdFTP1.ChangeDir(myDate);
end;
end;ملحوظة البرنامج كله مفتوح المصدر اذا اردت الاطلاع عليه اخبرنى


![[-]](https://delphi4arab.net/forum/D4A2020/collapse.png)