By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Need to lock read a text file, then delete...

P: n/a
Hi everybody,
I tried to find some information about my subject with google, but I
didn't find anything.

I need to read a text file, process the entire content, then kill. In
the meantime I have to be sure that no one could write on it. So I
opened with read write lock, but when i closed it, before deleting,
someone wrote something, and I lost the information because immediately
after I killed it.

Have you any suggestion?

Sorry for my bad english.

Thanks in advance,
Alessandro Noro

May 10 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Alessandro wrote:
Hi everybody,
I tried to find some information about my subject with google, but I
didn't find anything.

I need to read a text file, process the entire content, then kill. In
the meantime I have to be sure that no one could write on it. So I
opened with read write lock, but when i closed it, before deleting,
someone wrote something, and I lost the information because immediately
after I killed it.

Have you any suggestion?
Rename the file before you start reading it. That way, any writer will
(presumably) find the file missing, and create a new blank one to write
to.

I guess we are talking about parsing a log file or something like that?
Sorry for my bad english.


Better than my Italian.

--
Larry Lard
Replies to group please

May 10 '06 #2

P: n/a
Thanks Larry for your quick reply.

I thought about the solution You suggest me, but unfortunately I cannot
do so, because I could delete the Input file only if I could find other
files (depending on what I find inside the Input file). Otherwhise I
have to wait, and leave the Input file "free" for more writings.
I also thought about reading the Input file, then remove all the lines
inside, leaving it empty. But I don't know how to do this...

Thanks again.
Alessandro Noro

May 10 '06 #3

P: n/a
Copy the file to another location.
Delete the file
Create the new file for new additions
Do the processing of the file in your code at the new location.
Delete file at new location so you can do the same next time.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Alessandro" <no***@seait.it> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks Larry for your quick reply.

I thought about the solution You suggest me, but unfortunately I cannot
do so, because I could delete the Input file only if I could find other
files (depending on what I find inside the Input file). Otherwhise I
have to wait, and leave the Input file "free" for more writings.
I also thought about reading the Input file, then remove all the lines
inside, leaving it empty. But I don't know how to do this...

Thanks again.
Alessandro Noro

May 10 '06 #4

P: n/a
Allessandro

This is an old Jewish witz

Bram asks to the Rabi: "Rabi can God make everything he wants?
The Rabi answers: "Yes of course Bram"
Bram asks: "Rabi can God make a stone which he cannot lift himself?

Your question sounds the same for me.
(I never forget this witz because there is so much true in it).

Cor

"Alessandro" <no***@seait.it> schreef in bericht
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks Larry for your quick reply.

I thought about the solution You suggest me, but unfortunately I cannot
do so, because I could delete the Input file only if I could find other
files (depending on what I find inside the Input file). Otherwhise I
have to wait, and leave the Input file "free" for more writings.
I also thought about reading the Input file, then remove all the lines
inside, leaving it empty. But I don't know how to do this...

Thanks again.
Alessandro Noro

May 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.