[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Reading a log file without locking it

Hello,

I have a problem reading a text file.
I'm trying to read a log file, that is often written by an application. I'm tryin to make a sort of real-time-log-viewer.

I tried to open and read it with readln and with readfromfile but when the software reads the log, the writing application fails to write some rows and then the log is incomplete.

Can someone help me??

Thank you very much

Roberto
0
roburobe
Asked:
roburobe
1 Solution
 
mokuleCommented:
What procedure do You use for reading?
0
 
k4hvd77Commented:
hi,
don't know if it Could work, but just an idea!
make a copy from the File, open the copy, do your Operation and than delete it. "copyfile(PChar('SourcePathFileNameHere'),PChar('TargetPath[FileName]Here'),True)"


k4hvd77
0
 
kretzschmarCommented:
if u use reset()

then set before

filemode := 0;  //open file for read


if you use a tfilestream use

fmOpenread or fmShareDenyNone

just from head

meikl ;-)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
roburobeAuthor Commented:
Meikl, thank you very much and sorry for earlier mistake....

Roburobe
0
 
kretzschmarCommented:
glad to helped you :-))

meikl ;-)
0
 
roburobeAuthor Commented:
and what about the .loadfromfile???

Is there a way to execute this method in read-only mode?
0
 
kretzschmarCommented:
>Is there a way to execute this method in read-only mode?

no, not direct,
you could use something like this

var
  f : TFileStream;
begin
  f := TFileStream.Create('YourLogFileNameHere',fmOpenRead or fmShareDenyNone);
  memo1.lines.loadfromStream(f);
  f.free;
end;


meikl ;-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now