Hello,
I have a compiler warning in following code 'F might not be
initialized', at the M.LoadFromStream(F); line.
M := TMemoryStream.Create;
try
for n := 0 to FFiles.Count - 1 do begin
try
F := TFileStream.Create(FFiles[n], fmOpenRead or fmShareDenyWrite);
except
TriggerWarning('Could not open ''' + FFiles[n] + '''');
Continue;
end;
M.LoadFromStream(F);
F.Free;
if not DeleteFile(FFiles[n]) then
TriggerWarning('Cannot delete file ''' + FFiles[n] + ''', will not
transmit it.')
else
// Todo: add to database and transmit it
end;
finally
M.Free;
end;
However unless my brain is damaged due to late hours work, it should
always be initialized because if exception occure I 'continue' the loop.
The TriggerWarning fires an event (yeah I know DoWarning is be more
used), and FFiles is a TStringList containing filenames in a given
folder.
What I'm trying to do is read files generated by another application,
open them, do something with it and delete it. The other application may
not change the file after I open it of course.
Can I make the compiler happy, or make some better code to etablish this
?
---
Rgds, Wilfried
http://www.mestdagh.biz
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk