Autor Beitrag
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 20:16 
Ich suche eine Lösung für das folgende Problem:

Ich schreibe gerade an einem Programm, dass Dateien, die den selben Namensanfang (alles vor dem ".") haben. Zum Beispiel also Delphi-Dateien *.dpr, *.cfg, *.dof.

Wie kann ich das ermitteln?
Also ich habe ein schon eine dieser Dateien und will nun alle weiteren Dateien mit diesem Namensanfang einer ListView hinzufügen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 20:22 
suche mal hier im forum, da wurde schon mal erklärt, wie man in einem string dinge suchen kann. du kannst den letzten punkt suchen, und alles davor ist dan das zu vergleichende zeug.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 21:01 
Ich habe schon im Forum gesucht, aber das bischen, was ich fand war mir nicht gerade hilfreich.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 21:03 
suche mal nach den wörtern pos, length, string...
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 21:09 
Mein Problem ist nicht so sehr die Dateinamenerweiterung los zu werden. Ich muss aber herausbekommen, ob weitere Dateien in dem selben Verzeichnis sind, die bis auf die Dateinamenerweiterung gleich benannt sind. Ganz egal, ob es 2 oder 999 sind.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: So 02.03.03 21:45 
naja! vergleiche einfach den dateinamen, bin zum letzten punkt, und wenn 2 gleich sind, dann stimmen sie bis auf die dateiendung überein, und dazu brauch man solche funktionen
Thunderman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 26



BeitragVerfasst: So 02.03.03 22:16 
Hallo!

Benötigt werden sollten eigentlich nur diese Dinge:
Um die Dateien zu finden:
-FindFirst
-FindNext
-FindClose
Und um die Dateinamen zu vergleichen:
-Pos und Length
-Copy
Eventuell noch ein Array, in dem Du die Namen der Dateien ohne Endung speicherst, wenn Du jede mit jeder vergleichen willst, und nicht nur mit einem festen String.

_________________
Thunderman
Bei schwierigen Problemen entscheiden wir uns einfach für die richtige Lösung. Klar?
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 23:06 
Also das geht schon in die Richtung, die ich suche. Danke.
Ich teste das mal und werde wieder schreiben wie es ging.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 03.03.03 11:48 
Also ich bin jetzt so weit:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
if FindFirst(Pfad, 0, Suche) <> 0 then
    begin
      ListBox1.Items.Add(Suche.Name);

      repeat
        FindNext(Suche);
        ListBox1.Items.Add(Suche.Name);
      until
        FindNext(Suche) <> 0;

      FindClose(Suche);
    end;


Aber seitdem heißt es immer Undefinierter Bezeichner ListBox1, wobei zu erwähnen ist, dass der Name der ListBox wirklich ListBox1 ist.

Kann mir jemand sagen, wo der Fehler ist?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.03.03 11:54 
Zeig mal deinen Prozedur-Kopf.

Mach die Prozedur zur einer Methode von TForm1, dann sollte es gehen.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 03.03.03 12:05 
Das hier ist der ganze Code der Prozedur:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TeileWaehlen(DateiName: String);
var
  NameOhneEnd, Pfad: String;
  Suche: TSearchRec;
begin
  NameOhneEnd := EntfEnd(DateiName);
  Pfad := NameOhneEnd + '.*';

  if FindFirst(Pfad, 0, Suche) <> 0 then
    begin
      LsB_Files.Items.Add(Suche.Name);

      repeat
        FindNext(Suche);
        LsB_Files.Items.Add(Suche.Name);
      until
        FindNext(Suche) <> 0;

      FindClose(Suche);
    end;
end;

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.03.03 12:08 
Sag ich doch: Keine Methode von deiner Form. Wie soll da das private Symbol Lsb-Files bekannt sein? Also mach es zu einer methode deiner Form und gut ist.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 03.03.03 12:11 
Danke, das war der Fehler. Da habe ich überhaupt nicht mehr dran gedacht.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.