Solved

Reading a log file without locking it

Posted on 2004-03-30
7
330 Views
Last Modified: 2010-04-05
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
Comment
Question by:roburobe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10711784
What procedure do You use for reading?
0
 
LVL 4

Expert Comment

by:k4hvd77
ID: 10711785
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
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 10711797
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:roburobe
ID: 10711976
Meikl, thank you very much and sorry for earlier mistake....

Roburobe
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10711992
glad to helped you :-))

meikl ;-)
0
 

Author Comment

by:roburobe
ID: 10712876
and what about the .loadfromfile???

Is there a way to execute this method in read-only mode?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10712902
>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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question