i have problem if more than one client access 1 file with this method in datasnap at the same time:

i have problem if more than one client access 1 file with this method in datasnap at the same time:

function TServerMethods.DownloadJPEGFile(sFilePath: string): TJSONArray;
var
  strFileStream: TFileStream;
begin
  strFileStream := TFileStream.Create(sFilePath, fmOpenRead);
try
  Result := TDBXJSONTools.StreamToJSON(strFileStream, 0, strFileStream.Size);
finally
  strFileStream.free;
end;
end;

error message: cannot acces the file because it is being used by another prosess.

how to make this file can access more than client in the same time.

Comments

  1. Use the TFileStream constructor with specified share mode smDenyNone

    ReplyDelete
  2. Thanks you Ondrej Kelle​​. Did you mean TFileStream.Create(Path, fmOpenRead or fmShareDenyNone). My problem fix

    ReplyDelete

Post a Comment