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

file IO, only 1 update at a time

I am sure there is an easy solution to this. I have an
absolute bullet proof requirement that only 1 application
at a time can update a file.

I know that if I Use:
System.IO.Stream fs= File.OpenWrite(fiPath);
No on else can open the file even for reading, (
unfortunately I can't either )

but what I need is to open the file exclusively, read the
text exclusively, then update it - and keep other
appliucations out until the update is done.

If I read first then the argument is being made that some
other application could have gotten in an changed the
content.

Can anyone share there snippet with me ? Thanks
Nov 15 '05 #1
1 1006
andrewcw wrote:
|| I am sure there is an easy solution to this. I have an
|| absolute bullet proof requirement that only 1 application
|| at a time can update a file.
||
|| I know that if I Use:
|| System.IO.Stream fs= File.OpenWrite(fiPath);
|| No on else can open the file even for reading, (
|| unfortunately I can't either )
||
|| but what I need is to open the file exclusively, read the
|| text exclusively, then update it - and keep other
|| appliucations out until the update is done.
||
|| If I read first then the argument is being made that some
|| other application could have gotten in an changed the
|| content.
||
|| Can anyone share there snippet with me ? Thanks

Use:
System.IO.Stream fs FileStream(fiPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);

That way you open the file for update and prevent others to open the file (exclusive open).

Willy.
Nov 15 '05 #2

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

Similar topics

10
by: Kenneth McDonald | last post by:
I could've sworn python had such a command, but now I can't find it... I'm looking for an easy way to perform a UNIX-style "touch", to update the modification time of a file without actually...
2
by: Ted Duross | last post by:
Hi, I’ve created an educational software application accessed by students from a central server. On Start-Up the application reads an XML file that stores student progress records. This XML...
6
by: Chang | last post by:
How to get SHA1 or MD5 of a big file (+5MB - 20GB) as I can't read 20GB into memory. -- Chang.
5
by: Wayne Wengert | last post by:
I want to have my application (VB.NET) check a table on an SQL server to see if there is a newer version released and, if so, download and install the new version. I know how to setup the database...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
4
by: thisis | last post by:
Hi All, i'm trying to display the amout in percentage for the loading sub event value, for the <img .../> example: the browser should display something like this:
8
by: rdemyan via AccessMonster.com | last post by:
Anyone have any ideas on how to determine when the back-end file (containing only tables) has been updated with new data. The date/time of the file won't work because it gets updated to the...
6
by: | last post by:
Hi, I'm steel trying to read and update my XML file with Visual Basic Express but i am unable to find the right way to read my xml file and update it if neccessary... Here is my problem :...
9
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.