I download an EXE file from the Internet using Indy (idHTTP), and I can use memystream or filestream to save it to disk, but I really donβt know if there is a difference between them (maybe in the structure of the result file?). I could not find the answer to this question.
Here, where are two simple functions to simulate what I am doing:
Function DownloadMS(FUrl, Dest: String): Boolean; var Http: TIdHTTP; Strm: TMemoryStream; Begin Result := False; Http := TIdHTTP.Create; Strm := TMemoryStream.Create; With Http, Strm Do Try Try Get(FUrl, Strm); If (Size > 0) Then Begin Position := 0; SaveToFile(Dest); Result := True; end; Except end; Finally Strm.Free; Http.Free; end; end; Function DownloadFS(FUrl, Dest: String): Boolean; var Http: TIdHTTP; Strm: TFileStream; Begin Result := False; Http := TIdHTTP.Create; Strm := TFileStream.Create(Dest, fmCreate); With Http, Strm Do Try Try Get(FUrl, Strm); Result := (Size > 0); Except end; Finally Strm.Free; Http.Free; end; end;
What do you experts think about using this or that type (memystream or filestream)? Is there any difference in the structure of an EXE file when using this or that type? Which type is recommended?
Thanks! Good weekend!
source share