# How to open file using TROBinaryMemoryStream just to read something?

**URL:** https://talk.remobjects.com/t/how-to-open-file-using-trobinarymemorystream-just-to-read-something/31227
**Category:** Remoting SDK
**Tags:** delphi
**Created:** [December 19, 2024, 1:38pm UTC](https://talk.remobjects.com/t/how-to-open-file-using-trobinarymemorystream-just-to-read-something/31227 "2024-12-19T13:38:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Marcos\_Cunha\_Lima](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Marcos\_Cunha\_Lima](https://talk.remobjects.com/u/Marcos_Cunha_Lima)
#### Post date: [December 19, 2024, 1:38pm UTC](https://talk.remobjects.com/t/how-to-open-file-using-trobinarymemorystream-just-to-read-something/31227/1 "2024-12-19T13:38:38Z")

</div>

Hi

I am trying to transfer a log file from server to client using TRoBinaryMemoryStream.  
The problem I am having is that the log system is using the file to write and it prevents me from opening the file if I use the following code:

```auto
function TautenticacaoService.GetArquivoLog: binary;
begin
  result := TROBinaryMemoryStream.Create;
  result.LoadFromFile(Logger.currentLogFileName);
end;

```

I am wondering if I could use (how?) flags to signal the writer that I am just opening the file to read it, like:

```auto
TFileStream.Create(NomeArquivo, fmOpenRead or fmShareDenyNone)

```

Is there a way to do that using RO classes?

---

<div class="post-metadata">

### Author: ![Marcos\_Cunha\_Lima](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Marcos\_Cunha\_Lima](https://talk.remobjects.com/u/Marcos_Cunha_Lima)
#### Post date: [December 19, 2024, 1:56pm UTC](https://talk.remobjects.com/t/how-to-open-file-using-trobinarymemorystream-just-to-read-something/31227/2 "2024-12-19T13:56:08Z")

</div>

Answering my own question:

```auto
function TautenticacaoService.GetArquivoLog: binary;
var
  readLogStream : TFileStream;
begin

  readLogStream := TFileStream.Create(Logger.currentLogFileName, fmOpenRead or fmShareDenyNone );
  try
    result := TROBinaryMemoryStream.Create;
    result.LoadFromStream(readLogStream);
  finally
    readLogStream.Free;
  end;

end;

```
