I have a problem with an application I'm writing where files are spontaneously closed for no real reason. In one part, I have
AssignFile(FileS100, Filename);
Reset(FileS100);
For k := 0 to (FileSize(FileS100)-1) do
begin
Seek(FileS100, k);
The file is closed between the start of the loop and the seek (putting ShowMessage(IntToStr(FileSize(FileS100))) just before the loop gives the correct size).
In another place I have
Filename := 'Check.tmp';
AssignFile(TempFile, Filename);
Rewrite(TempFile);
{Loads of code (including loops and whatnot)}
CloseFile(TempFile);
If Not DeleteFile('Check.tmp') then ShowMessage('TempFile error');
It says file not open at the CloseFile. The only other CloseFile command in that section of code is for a file with a completely different variable name so I haven't typed it wrong and already closed it. Also, the file is read from, written to and seeked a lot in the code between the rewrite and the closefile and none give me any errors.
Any ideas?
AssignFile(FileS100, Filename);
Reset(FileS100);
For k := 0 to (FileSize(FileS100)-1) do
begin
Seek(FileS100, k);
The file is closed between the start of the loop and the seek (putting ShowMessage(IntToStr(FileSize(FileS100))) just before the loop gives the correct size).
In another place I have
Filename := 'Check.tmp';
AssignFile(TempFile, Filename);
Rewrite(TempFile);
{Loads of code (including loops and whatnot)}
CloseFile(TempFile);
If Not DeleteFile('Check.tmp') then ShowMessage('TempFile error');
It says file not open at the CloseFile. The only other CloseFile command in that section of code is for a file with a completely different variable name so I haven't typed it wrong and already closed it. Also, the file is read from, written to and seeked a lot in the code between the rewrite and the closefile and none give me any errors.
Any ideas?