eksport listy podkatalogów do label'a

0

Witam mam taki problem jak wyeksportować z DirectoryListBox do Label'a lub Memo listę samych podkatalogów, np. mam ścieżke C:\folder1(reszta folderów) i jak w Lebelu umieścić samą "reszte folderów" bez "C:" i "folder1" ?

0

U mnie działa taki kod:

Najpierw dajemy takie dwie funkcje:

function IsSlash(const sText: String) : String;
begin
if sText[Length(sText)] <> '\' then Result := sText + '\' else Result := sText;
end;



Function  FindFolders(Directory:String;Lines:TStrings): Integer;
var
  SR: TSearchRec;
  Found,FOUNDED : Integer;
begin
Found := FindFirst(IsSlash(Directory) + '*.*', faDirectory, SR);
FOUNDED:=0;   //ILOŚĆ ZNALEZIONYCH FOLDERÓW
while (Found = 0) do

  begin
    if not FileExists(IsSlash(Directory)+SR.Name) then
        BEGIN
        if ((SR.Name<>'.') and (SR.Name<>'..')) then  Lines.add(SR.Name);
        FOUNDED:=FOUNDED+1;
        END;
    Found := FindNext(SR);
  end;
    FindClose(SR);
    Result:=FOUNDED;
end;

Kładziemy na forme komponenty np:

Label, Memo i DirectoryListBox
i w zdarzeniu "OnChange" tego ostatniego dajemy:

Label1.Caption:=DirectoryListBox1.Directory;
Label1.Caption:=IsSlash(Label1.Caption);
Memo1.Clear;

FindFolders(Label1.Caption,Memo1.Lines);

W memo pojawia sie lista podfolderów... przynajmiej powinna :-)

1 użytkowników online, w tym zalogowanych: 0, gości: 1