473,402 Members | 2,061 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,402 software developers and data experts.

Access to file

Hi,

I have the following situation:

-app1 writes data to a file
-app2 (a service) is notified when the file is changed using the
FileSystemWatcher
-app2 reads the last added data and should remove the read data from the
file

Well, I think I can get a problem, if app1 tries to write data to the file,
while app2 is removing the content from the file at the same time. How can
this problem be solved?
Christian
Jan 18 '08 #1
5 1300
Hi,

Can you use some other mechanism than a file?
Otherwise, can you create separated files each time App1 has something to
write (App2 can delete the consumed files afterwards)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Christian Havel" <Ch************@discussions.microsoft.comwrote in
message news:58**********************************@microsof t.com...
Hi,

I have the following situation:

-app1 writes data to a file
-app2 (a service) is notified when the file is changed using the
FileSystemWatcher
-app2 reads the last added data and should remove the read data from the
file

Well, I think I can get a problem, if app1 tries to write data to the
file,
while app2 is removing the content from the file at the same time. How can
this problem be solved?
Christian

Jan 18 '08 #2
For this very reason, when you try and write to a file the operating
system will lock the file preventing other applications from using it.
I think you can use the FileSystemMonitor to tell you when this lock
is removed. Then you know when it is safe to try and write to it.

The other way to do it is to ensure that only app1 actually writes to
the file. You could do this by having another file written to by app2
telling app1 what data needs to be deleted.

Jan 18 '08 #3
Thanks for your help.
Is the file locked if I only read from it, too?
Christian

"Olie" wrote:
For this very reason, when you try and write to a file the operating
system will lock the file preventing other applications from using it.
I think you can use the FileSystemMonitor to tell you when this lock
is removed. Then you know when it is safe to try and write to it.

The other way to do it is to ensure that only app1 actually writes to
the file. You could do this by having another file written to by app2
telling app1 what data needs to be deleted.

Jan 18 '08 #4
The file lock allows multiple readers but only one writer.

When the file is locked for writing only that application may write or
read from the file.

When a file is locked for reading any application can read from that
file and no application can write to it.

Jan 18 '08 #5
Thanks Olie :-)

"Olie" wrote:
The file lock allows multiple readers but only one writer.

When the file is locked for writing only that application may write or
read from the file.

When a file is locked for reading any application can read from that
file and no application can write to it.

Jan 21 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
2
by: PhilBTL | last post by:
The shipping software we currently use stores our customer address in an Access database file. I need to import these records into a new shipping system that does not read Access files. Does anyone...
4
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
3
by: Clodoaldo Pinto Neto | last post by:
Hi all, I'm restoring a database from 7.3.4 FC1 to 7.4.2 FC2: $ pg_restore -d KakaoStats KakaoStats.dump pg_restore: could not execute query: ERROR: could not access file...
10
by: Minh | last post by:
I search in all the Disscussion but can not found. How can I create a MS Access Database file using C# code with a given Table Structure ? For example, I want to create a Access Database File...
3
by: VB.NET | last post by:
I'm using a mysql database and connecting my vb.net program to the DB over a network connection. i would like to bring this data over to a vb.net random access file. does anyone know how to...
4
by: klynn | last post by:
Hi: I'm having problems reading a Microsoft Access file from my ASP.Net app on a Windows Server 2003 machine. The error message: The Microsoft database engine cannot open the file, <my_file>. It...
12
by: Dr. Edmund M. Hayes | last post by:
I wrote a access program that works well enough that a handful of people would like to buy it from me. My problem is that if I sell it to someone there is no mechanism that I know of to protect...
4
by: greg | last post by:
Hi, I have a read only access file with a linked table that connects to a sybase database. So I can still add data to the table even though its read only since the table is really in sybase. ...
24
by: dancer | last post by:
Using ASP.net 1.1 and Microsoft Access. I received the following error message. Why? I have closed the Access file. I have another very small access file that opens with no trouble with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.