473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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
4 2431

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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
1
by: Nand Belani | last post by:
Hi, I have a MS Access 2000 database on the network, it is secured and the mdw file is on the network. The database works for most of the users on the network, but does not open for two of the...
8
by: Chris | last post by:
Hi, All my websites and webservices are down. I get the following message Server Error in '/mywebservices' Application....
3
by: AVL | last post by:
Hi, I need some info on text and xml files...... How many users can simultaneously read a text or xml file... I've a web appliaction which needs to access a text file and a xml file.. The...
4
by: Peter | last post by:
Hi,everybody, I will edit a text file and another user maybe read it via LAN at any time. I want to lock the text file(no reading and writing) while I am editting. Anyone can help me? Thanks...
5
by: pgdown | last post by:
Hi, I have several processes accessing files from one folder, but only one process should ever access each file. Once one process has the file, no other process should be allowed to access it,...
6
by: RLN | last post by:
RE: Access 2003 My users have an .MDE as their front end. With this .mde they can still get to the container, double click a table, and modify data on the back end. What is the best way to...
2
by: macneed | last post by:
Can i lock a file in c#, that i can move it and del it, but other program don't have right to access(read) until i release it? i read fileshare.none, but can't delete it without close the...
25
by: zmickle | last post by:
Excuse my noobness. I am managing an access database that is shared by 4 users. Management does not want to use any technologies outside of access for this application (no SQL Server, etc). I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.