Autor Beitrag
Scotch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 6 Prof
BeitragVerfasst: Mo 04.11.02 20:09 
Hallo leutz,
Ich habe eine daten bank in der ich als String den Path von einem Bild habe. das öffnen und so weiter funktioniert ja auch. nur wenn sich das Verzeichnis von den Bildern ändert muss ich so um die 500 Datensätze ändern. :evil: Aber das kann es doch nicht sein. Aber ich sehe den Wald vor lauter Bäumen nicht.....

Wie stell ich das an das in meien DB nur der name der Datei und nicht der ganze Path steht. So sieht es z.Z bei mir aus.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
var Path :string;
begin
  path := FileListBox1.FileName;
  label1.Caption := FileListBox1.FileName;
  path := FileListBox1.FileName;
  //if path = '*.jpg'  then
  image1.Picture.LoadFromFile(FileListBox1.FileName);

Das Caption von Label1 gebe ich dan an meine DB weiter.

Cu Scotch
phlux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mo 04.11.02 20:44 
Moinsen Pansen, versuchs mal einfach wenn du den Pfad zu den Bildern hin in deine DB schreibst einfach nur mal mit
ExtractFileName('Path');
Das gibt dir nur den Dateinamen!

_________________
Chaos-Raid Soft*
phlux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mo 04.11.02 20:50 
Scotch hat folgendes geschrieben:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
var Path :string;
begin
path := FileListBox1.FileName;
 label1.Caption := FileListBox1.FileName;
  path := FileListBox1.FileName;
  if ExtractFileExt(path) = '.jpg'  then
  image1.Picture.LoadFromFile(FileListBox1.FileName);



So funzt et

_________________
Chaos-Raid Soft*
Raphael82
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.11.02 23:05 
Yep und Nein, denn du hast vergessen, das einzubinden, was du einbinden wolltest: ExtractFileName(); :D

Also posten wir nochmal den selben Code:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var path :string; 
begin 
path := ExtractFileName(FileListBox1.FileName); 
label1.Caption := path; 
 try 
  image1.Picture.LoadFromFile(FileListBox1.FileName); 
 except
  ShowMessage(Fehler! Konnte Datei nicht öffnen!');
 end;


Habe unnötigen Quelltext noch entfernt. Die Abfrage per
"if ExtracFileExt()" ist nicht optimal, weil es nicht sicher ist, ob die Datei geöffnet werden kann, oder sie überhaupt ein Bild ist. Deswegen Try/Except. Wenn du den genauen Fehler anzeigen lassen willst, warum die Datei nicht geöffnet werden konnte, musst du den exception-Teil dementsprechend erweitern, doch ich denke so wie's ist sollte es doch ausreichen.

MfG, Raphael

_________________
Share your knowledge to receive perfection!
Scotch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 6 Prof
BeitragVerfasst: Mo 04.11.02 23:16 
Jo Danke, habt mir sehr geholfen :lol:
gruß Scotch
alexschultze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 317



BeitragVerfasst: Di 05.11.02 11:47 
ach so, noch eine Bitte:
Wäre nett wenn du für die Community immer ein halbwegs eindeutiges Topic deines Beitrages schreiben würdest. Ich z.B. sehe mir nur Threads an denen ich etwas abgewinnen kann oder wo ich evtl. kompetent sein könnte und helfen könnte (leider bisher noch nicht vorgekommen *gg*, kommt aber noch *g*).
Wenn irgendwann jeder Beitrag "Wie geht das?" oder "Kann mir das einer erklären?" heisst, würde das Forum doch unübersichtlich ;)
okay? Klare Topics sind gesund, auch wenn man mal kurz grübeln muss wie man es in dieses kleine Feld quetscht *g*