Autor Beitrag
Tulkas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 21

WinXP SP2
Delphi7
BeitragVerfasst: Di 14.11.06 10:20 
Hallo!

Beim OnCreate des Hauptformulars, prüfe ich ob eine bestimmte Datei vorhanden ist. Wenn nicht, erstelle ich diese mit FileCreate('config.cfg', fmOpenReadWrite);
und es wird ein Formular geöffnet, wo man über Edits verschiedene Werte eingeben kann. Durch einen klick auf einen Button soll die Datei dann gespeichert werden. Das klappt aber nur, wenn die Datei schon vorhanden ist; nicht wenn sie erst erstellt werden muss.
didiwerdau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67

Win 2000
C# 2008 Express Edition
BeitragVerfasst: Di 14.11.06 10:26 
kann das sein, dass du die Datei zwar erstellst, aber dann nicht öffnest?
Tulkas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 21

WinXP SP2
Delphi7
BeitragVerfasst: Di 14.11.06 10:31 
Doch, eigentlich schon. Ich öffne die Datei mit

AssignFile(F, 'config.cfg');
FileMode := 2;
Reset(F);

Wie gesagt, wenn die Datei vorhanden ist, funktioniert das Speichern, nur nicht wenn die Datei erstellt werden muss.
didiwerdau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67

Win 2000
C# 2008 Express Edition
BeitragVerfasst: Di 14.11.06 11:02 
Kann es sein, dass die Datei schreibgeschützt erstellt wird?
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Di 14.11.06 11:06 
Hallo,

zum schreiben verwendet man Rewrite() anstatt Reset. Außerdem würde ich dir dringen empfehlen auf TFileStream umzusteigen, dann musst du dich nicht mehr mit alten Funktionen herumschlagen!

Viele Grüße,
Hape

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Tulkas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 21

WinXP SP2
Delphi7
BeitragVerfasst: Di 14.11.06 12:17 
Ok, mit Rewrite hat's geklappt! Danke!!