title: Delphi - MemoryStream or FileStream
body: <p>I am downloading an EXE file from internet using Indy (idHTTP), and I can use memorystream or filestream to save it to disk, but I really do not know if there is any difference between them (maybe in the result structure of the file?). I could't find yet an answer for this.</p>
  
  <p>Where, here are 2 simple functions to simulate what I am doing:</p>
  
  <pre><code>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 &gt; 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 &gt; 0);
      Except
      end;
    Finally
      Strm.Free;
      Http.Free;
    end;
  end;
  </code></pre>
  
  <p>What you experts think about using one or other type (memorystream or filestream)? Is there any difference in the structure of the EXE file when using one or other type? What type is recommended?</p>
  
  <p>Thank you! Have a nice weekend!</p>