The tool I am writing is responsible for uploading thousands of image files in a matter of hours. Initially, using TIdHTTP
, I would Get
file (s) in TMemoryStream
, and then save it to a file if there were no exceptions. To improve speed, I changed TMemoryStream
to TFileStream
.
However, now if the resource was not found or by any other exception that does not result in the actual file, it saves the empty file.
Fully understandable, since I just create a file stream just before downloading ...
FileStream:= TFileStream.Create(FileName, fmCreate);
try
Web.Get(AURL, FileStream);
finally
FileStream.Free;
end;
I know that I can simply delete the file if an exception occurs. But it seems too sloppy. I am sure that there is a more suitable way to end this situation.
, , , ( )?