Kako da sadrzaj odredjenog direktorijuma iscitam u listbox?
Izlistavanje sadrzaja foldera
Zaključano
Zakačeno
FindFirst, FindNext i FindClose su funkcije koje se koriste za takve stvari, ako hoces i sadrzaje poddirektorija onda ces morati i rekurziju koristiti.
Potpis
the world is not enough ...
Code:
procedure FeedToListBox(const path, FileExt : String);
var
SearchRec : TSearchRec;
begin
If FindFirst(Path + FileExt, $0000003F - $00000010, SearchRec) = 0 Then
repeat
// Ovde stavis sta da radi (ListBox1.Items.Add)
until FindNext(SearchRec) <> 0;
If FindFirst(Path + '*.*', $00000010, SearchRec) = 0 Then
repeat
If (SearchRec.Attr and $00000010 <> 0) and
(SearchRec.Name <> '.') and
(SearchRec.Name <> '..') and
(Pos(WinDir, SearchRec.Name) = 0) Then
FeedToListBox(Path + SearchRec.Name + '\', FileExt);
until FindNext(SearchRec) <> 0;
FindClose(SearchRec);
procedure FeedToListBox(const path, FileExt : String);
var
SearchRec : TSearchRec;
begin
If FindFirst(Path + FileExt, $0000003F - $00000010, SearchRec) = 0 Then
repeat
// Ovde stavis sta da radi (ListBox1.Items.Add)
until FindNext(SearchRec) <> 0;
If FindFirst(Path + '*.*', $00000010, SearchRec) = 0 Then
repeat
If (SearchRec.Attr and $00000010 <> 0) and
(SearchRec.Name <> '.') and
(SearchRec.Name <> '..') and
(Pos(WinDir, SearchRec.Name) = 0) Then
FeedToListBox(Path + SearchRec.Name + '\', FileExt);
until FindNext(SearchRec) <> 0;
FindClose(SearchRec);
malo je ruzno sa konstantama tipa $0000003F $00000010
bolje je koristiti imena, da se zna sta je sta :)
bolje je koristiti imena, da se zna sta je sta :)
Potpis
Čini mi se da u Delphiju već postoji takav jedan ListBox, ako ti treba već gotova stvar. Potraži po paleti; ako ništa drugo, možeš pogledati source...
Potpis
Yea, and from this day forth, a surface must be locked before beast or man can draw upon it!
Citat:
bancika: malo je ruzno sa konstantama tipa $0000003F $00000010
bolje je koristiti imena, da se zna sta je sta
bolje je koristiti imena, da se zna sta je sta
Eh da, zamenio sam ih zato sto u mom programu nisam koristio SysUtils.