Solved

Reading a log file without locking it

Posted on 2004-03-30
7
328 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

803 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