I\O error 103 (Delphi XE3)
Why does the error pop up when processing the file: I\O error 103 ?
var
fall, f1: TextFile;
S: string;
begin
AssignFile(fall, OpenDialog1.FileName);
reset(fall);
if CheckBox1.Checked then
begin
AssignFile(f1, 'Organization.txt');
rewrite(f1);
end;
//работаем по строкам в файле
while not Eof(fall) do
begin
//читаем строку
ReadLn(fall, S);
if CheckBox1.Checked and (Pos(AnsiLowerCase(Edit1.Text), AnsiLowerCase(s)) > 0) then
writeln(f1, S);
end;
CloseFile(fall);
CloseFile(f1); // <<-- Ошибка выскакивает тут
end;
4
2 answers
if CheckBox1.Checked then
CloseFile(f1);
1
Author: Igor, 2018-02-24 18:07:17
The error, with a high degree of probability, happens because you open the files for reading/writing by condition, but then close the file in any case. Most likely, one of the conditions:
if CheckBox1.Checked then
if CheckBox2.Checked then
if CheckBox3.Checked then
You are not running, but you are doing CloseFile
for all files without conditions. Correct this by entering the same conditions for CloseFile
.
3
Author: Viktor Tomilov, 2018-02-26 06:17:30