delphiwinapi

How to read a file that is in use by other process?


I have an application that have a log system that create a file and keep it handle with a TFileStream, that is created with this way:

FFileStream := TFileStream.Create(FFilename, fmOpenWrite);

Ok. When I try to open this file with notepad, no problem, with notepad++ no problem. When I try to load the file with other application that I created it raise my an error that says the file is in used by other process.

I tried TStringList, LoadFromFile and TFileStream.Create(LFile, fmOpenRea);.

Some one knows how I can read this like the notepad and notepad++?


Solution

  • Use fmOpenWrite or fmShareDenyNone to enable sharing.