velolkp.blogg.se

Delphi tfilestream read text file
Delphi tfilestream read text file





delphi tfilestream read text file

I'm coding in Delphi and using the Windows and SysUtils units:įFileStreamOne := TFileStream.Create( fFileName, fmOpenRead or fmShareDenyNone ) įFileStreamTwo := TFileStream. any ideas? (I can't change the code for the app that's writing to the log) However, the app that needs to write to the file errors out w 'Cannot open log file C:\XXX.log' - it's trying to open the same file in fmOpenReadWrite or fmShareCompat. I have the file open in fmOpenRead or fmShareDenynone and have no issues with opening. afilest:TFileStream.Create c:mydata.dat,fmOpenRead) try //make sure file pointer is on beginning of file afilest.Seek (0,soFromBeginning) //read buffer afilest.

delphi tfilestream read text file

I wrote such a class for Secrets of Delphi 2, and if you look around, you might find a more current buffered stream class. You should use a buffered stream for that. var afilest : TFileStream tempdata: cardinal. TFileStream is unbuffered, so its not a good choice for reading and writing text. It does not check whether the intended number of bytes could actually be read. To load a file name c:mydata.dat for read access into stream and then read 4 bytes from beginning of file into a variable. My issue is that there is a process running that needs to write to the file which may be during the time I am reading. Note to self: TStream.Read in the Delphi RTL returns the number of bytes read. I have tried with FileStream, AssignFile and even CopyFile. I would like to scan a log file in read only mode w no locking.







Delphi tfilestream read text file