Autor Beitrag
akate-makate
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Di 16.03.10 20:52 
Hallo.Ich habe mit Hilfe des Internets den Code geschrieben.Das Problem ist das am Ende in der ListBox nichts angezeigt wird.Egal wenn ich z.B ein USB einlege und in der ListBox die Namen der Dateien angezeigt werden muessen,wird am Ende nichts angezeigt.Kann mir vielleicht jemand helfen?
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin, FileCtrl, ShellAPI, ComCtrls;

type
  TForm1 = class(TForm)
    DriveComboBox1: TDriveComboBox;
    Button1: TButton;
    DirectoryListBox1: TDirectoryListBox;
    ListBox1: TListBox;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure ListFileDir(Path: string; FileList: TStrings);
var
  SR: TSearchRec;
begin
  if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
  begin
    repeat
      if (SR.Attr <> faDirectory) then
      begin
        FileList.Add(SR.Name);
      end;
    until FindNext(SR) <> 0;
    FindClose(SR);
  end;
end;



procedure TForm1.Button1Click(Sender: TObject);
var
  direktori:string;
begin
  direktori:=DirectoryListBox1.Directory;
  ShowMessage(direktori);
  ListBox1.Clear;
  ListFileDir(direktori+'\', ListBox1.Items);
end;

end.

Mit der memo habe ich es auch versucht aber funktioniet wieder nicht.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure VerzeichnisEinlesen(dir:string);
    var SR: TSearchRec;
begin
  if dir[length(dir)]<>'\' then
    dir:=dir+'\';
  with Form1 do begin
    memo1.lines.Clear;
    memo1.WordWrap := false;
    memo1.Font.name := 'Courier New';
    if FindFirst(dir+'*.*',faAnyFile,SR)=0 then Begin
      repeat
          memo1.lines.add(sr.name+ ' ' + IntToStr(sr.size)+ ' ' +
             DateToStr(sr.Time));
      until FindNext(SR)<>0;
      FindClose(SR); //Nach jedem findfirst nötig, um sr freizugeben!
    End;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  direktori:string;
begin
  VerzeichnisEinlesen(direktori+'\');
end;

end.



Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 16.03.2010 um 19:58
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 16.03.10 21:12 
Moin!

Such mal nach Suche in: Delphi-Forum, Delphi-Library DRIVETOOLS LUCKIE, damit solltest du weiter kommen. :idea: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.