Autor Beitrag
TheHolyMan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 24.05.05 11:03 
ich habe 2 dateien .. wenn die Datei LayoutAnfang Existiert soll sie in das IMLayoutfile geschrieben werden .. ansonsten soll nichts gemacht werden.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
     try
        if fileExists(dtmCommon.LayoutDataPath + '\LayoutAnfang.txt') then begin
          AssignFile(DataFile,dtmCommon.LayoutDataPath + '\LayoutAnfang.txt');
          Reset(Datafile);
          while not Eof(Datafile) do begin
            ReadLn(Datafile,s);
            WriteLn(IMLayoutFile,s);
          end;

        end;
      finally
        {$I-}
        CloseFile(DataFile)
        {$I+}
      end;

      Write(IMLayoutfile,LayoutFileString);



Problem ist nun folgendes .. sobald ich zur zeile
ausblenden Delphi-Quelltext
1:
  Write(IMLayoutfile,LayoutFileString);					


komme Meldet Delphi einen I/O ERROR 103 ... und das auch wenn 'LayoutAnfang.txt' nicht existiert ...

Klammere ich aber

ausblenden Delphi-Quelltext
1:
CloseFile(DataFile)					


aus funktioniert alles ...
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Di 24.05.05 11:44 
Aber es ist alles richtig initialisiert und so?
Kann dazu nicht viel sagen, da mir die ganzen Variablen-Deklarationen fehlen.

Alstar
TheHolyMan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 24.05.05 12:37 
kößung:

kroko @ www.dsdt.info/

Zitat:

jetzt hab ich noch etwas gesehen:

wenn die Datei nicht existiert, wird nach finally die Datei in jedem Fall geschlossen

try finally end + F1

auch wenn sie gar nicht geöffnet wurde, dies löst den Fehler aus, den Du mit {$I}
abfängst und der dann in write (..) zu schlägt -> CloseFile in de If-Then-Block