Re: Can't understand why these exceptions occur...



Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@xxxxxxxxxxx> wrote in
news:sbh0k.36$sf2.8@xxxxxxxxxxxx:

<snip>
because you close a file that does not exist!

I'm afraid I have to disagree with you Jamie. From LoadCache:
---
if FileExists(cacheName) then
begin
AssignFile(cache, cacheName);
Reset(cache);
idx := 1;
while Not(eof(cache)) and (idx < Length(files)) do
begin
Read(cache, files[idx]);
Inc(idx);
end;
CloseFile(cache);
end;
---
The file will only be closed if it exists. If it doesn't, it's never
assigned nor closed. Now, from SaveCache:
---
AssignFile(cache, cacheName);
ReWrite(cache);
idx := 1;
while (idx < Length(files)) do
begin
if (files[idx].name <> '') then
begin
Write(cache, files[idx]);
end;
Inc(idx);
end;
CloseFile(cache);
---
Here, I rewrite the file, so it does exist at the time I close it.

So as you can see, there should be no problem with/when closing the file
IMHO.

Thanks,

Ikke
.