Could BinaryStream.Create() return too early?

Trying to nail down a problem that’s been haunting me for some time. A very few users are reporting issues saving a file from my application (Windows OS) where the application simply goes away. Nothing is found in the logs either.
The code to save the file looks like this:

  f = dlg.ShowModal
    
  if f <> Nil then
    if f.IsWriteable then
      try
        out_str = BinaryStream.Create(f, true)        
        out_str.Write attach
        out_str.Close
        
        dim w as new wndDownloadComplete
        w.Title = me.TrueWindow.Title
        w.TheFolderItem = f
        w.ShowModal
        
      catch err as RuntimeException
        Dialogs.FailureMessage(app.translate.langSubs1(97, f.NativePath), "", self)
      end try      
      default_save_directory = f.Parent      
    else
      Dialogs.FailureMessage(app.translate.strings(216), "", self)
    end if
  end if

I have a nagging feeling that the BinaryStream.Create() may behave when saving to a remote fileshare. Could the call return too soon so the Write() doesn’t work properly, but doesn’t raise an exception?

Can you name the service ?

I think he is talking about SMB (CIFS) file sharing. Like a mapped drive as Z:/mySharedFilesFolderInTheFileServer/

I read here that some services have to be avoided, that is why I asked.

A good test is to try the code on a local file, then on a different service, etc. Maybe.

It’s also Important to note that checking the readability or writeability of a file on a network share isn’t always reliable. different network file sharing mechanisms handle it in different ways, sometimes returning false regardless. You might want to create your own routine that tries to blindly create a file and then to read it.