473,770 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2453

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.goo glegroups.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.goo glegroups.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
5625
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 statements using the same iDB2Connection and iDB2Command. Then I want to Commit() so that either all the data goes in, or not. What happens though is this:
1
8715
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 users. It gives "CANNOT LOCK FILE" error. There is really no difference between these two users and the other users who can log on to the database. The rights to the shared directory, where the database resides are the same. can somebody advice me...
8
1705
by: Chris | last post by:
Hi, All my websites and webservices are down. I get the following message Server Error in '/mywebservices' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
3
1221
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 current users of the system are around 1000 people...
4
11927
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 in advance, Peter
5
4097
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, even after the first process is finished with it, except in the case where the first process crashes. In pseudo code.. * Open file with exclusive lock * Process file - failure will throw exception, skipping 'Remove
6
2216
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 lock the tables on the back end .mdb so they cannot get to the data?
2
4223
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 filestream or streamwriter there was still a cocurrency problem if i close the stream and delete it just after close what can i do?
25
14851
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 have split the database into front end and back end databases and put the front end on each of the users' computers. All users can open the front end simultaneously, but once somebody updates data in the form, the back end locks up. What I...
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.