Autor Beitrag
schermerbua
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Mo 13.06.05 19:37 
Ich habe ein Programm das mir textfiles erstellt, das speichern hab ich so gelöst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
test:= TStringList.Create;
  test.Add(Memo1.text+' Textfile produced by the one who can`t be named!');
  test.SaveToFile(edit1.Text+inttostr(p)+'.txt');
  test.Free;

Ich will jetzt aber dass das file an einen platz gespeichert wird, den der user bestimmen kann.
Als erstes brauch ich einen Savedialog. so weit komm ich von selber
aber:
-Wie kann ich dann vom Save dialog das verzeichnis auslesen lasssen?
-Wie muss ich die speicherprocedure ändern, damit dann das file in den bestimmten ordner gespeichert wird?
-wie kann ich im savedalog einstellen, dass er immer als txt speichert?
Danke für die Hilfe!

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 13.06.05 19:44 
Delphi-Hilfe hat folgendes geschrieben:
TSaveDialog zeigt ein modales Windows-Dialogfeld an, in dem der Benutzer einen Dateinamen eingeben oder markieren und eine Datei speichern kann. Das Dialogfeld wird zur Laufzeit erst angezeigt, nachdem es mit der Methode Execute aktiviert wurde. Wenn der Anwender auf die Schaltfläche Speichern klickt, wird das Dialogfeld geschlossen und der angegebene Dateiname in der Eigenschaft FileName gespeichert.


k?

danach brauchst du nur noch deinDialog.FileName auslesen.

_________________
[inspirationslos]
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Mo 13.06.05 20:32 
Und wie kann ich mit der speicherprocedure das file an den gewünschetn platz speichern lassen?
ausblenden Quelltext
1:
2:
3:
4:
test:= TStringList.Create;
  test.Add(Memo1.text+' Textfile produced by the one who can`t be named!');
  test.SaveToFile(edit1.Text+inttostr(p)+'.txt');
  test.Free;
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 13.06.05 20:38 
ich habs jetzt nicht gestestet, aber wie ich die hilfe da verstanden hab mit
user profile iconschermerbua hat folgendes geschrieben:

ausblenden Quelltext
1:
2:
3:
4:
test:= TStringList.Create;
  test.Add(Memo1.text+' Textfile produced by the one who can`t be named!');
  test.SaveToFile(deinDialog.FilenName);
  test.Free;

_________________
[inspirationslos]
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: Di 14.06.05 13:24 
Jo danke so funktionierts!
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mi 15.06.05 09:01 
noch ein kleiner hinweis:

pack am besten noch ein try-finally rein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
test:= TStringList.Create;  
try
  test.Add(Memo1.text+' Textfile produced by the one who can`t be named!');  
  test.SaveToFile(deinDialog.FilenName);  
finally
  test.Free; 
end;

falls das savetofile (oder wo anders) eine exception wirft würde sonst das free nicht aufgerufen werden und es würden speicherlöcher entstehen. ;-)

lg martin