Search code examples
delphidelphi-7

Debugger exception notification error for reading txt files in DELPHI


Im getting an error I haven't seen before.

Here's my code:

procedure TfrmPatientViewer.FormCreate(Sender: TObject);
var
  MyArray : array [1..100] of string;
  iCount : Integer;
  Patients : TextFile;
begin
  AssignFile(Patients, 'patients.txt');
  if FileExists('patients.txt') <> True
    then
      begin
        ShowMessage('Patients.txt does not exist, program shutting down');
        Application.Terminate;
      end;
  iCount := 1;
  while not Eof(Patients) do // <-- HERE'S THE ERROR
    begin
      Readln (Patients, MyArray[iCount]);
      redtOut.Lines.Add(MyArray[iCount]);
      inc(iCount);
    end;
end;

The error says: Project Phase3P.exe has raised an exception class ElnOutError with message 'I/O error 104'. Proccess stopped.

Why is it doing this and what can I do to make it work properly? I have searched around an can only find stuff on different I/O errors, but not this 104 one.


Solution

  • Okay, I found my error after proof reading for the 4th time xD

    I didn't put the reset(patients) after assigning the text file.