?
Solved

Reading a log file without locking it

Posted on 2004-03-30
7
Medium Priority
?
335 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 2000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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