I am working on an HTTP web server (via TIdHTTPWebBrokerBridge ) and have a little problem when it comes to uploading files to streams ( TFileStream ) that will be sent back to the client. This happens not every time, but in a rather random way ... I get an exception ...
Cannot open file "C:\SomePath\SomeFile.html". The process cannot access the file because it is being used by another process
This happens on this line:
Str:= TFileStream.Create('C:\SomePath\SomeFile.html', fmOpenRead);
(Str is a TFileStream )
I suppose the message speaks for itself, but I absolutely must avoid it. This exception occurs only in debug mode, but I need to debug this thing without worrying about getting this message all the time.
Oddly enough, most of the time the file is downloaded and sent back anyway.
How could I avoid this? And why does this not allow me to open it more than once, even if it is read only?
source share