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

Open file in exclusive mode

I am trying to open a file in exclusive mode for writing. Is the code
below correct?

FileStream oStream = File.Open(FileName, FileMode.Open,
FileAccess.Write, FileShare.None);

The purpose is two-fold:
1. I want no one to be able to open a file while I am operating on it.
2. If the file is open by someone else, I want the code above to throw
an exception.

Will it do the trick?
Thanks.
Nov 16 '05 #1
1 11435

"Frank Rizzo" <no**@none.com> wrote in message
news:O9**************@tk2msftngp13.phx.gbl...
I am trying to open a file in exclusive mode for writing. Is the code
below correct?

FileStream oStream = File.Open(FileName, FileMode.Open, FileAccess.Write,
FileShare.None);

The purpose is two-fold:
1. I want no one to be able to open a file while I am operating on it.
2. If the file is open by someone else, I want the code above to throw an
exception.

Will it do the trick?


Yep.

David
Nov 16 '05 #2

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

Similar topics

1
by: sixsoccer | last post by:
I posted this last week, and did not receive a response. I thought I would try one more time. Any help would be much appreciated. Thanks Bill I have three databases running, all with a...
0
by: Aaron | last post by:
Hi Guys, I have a dbase installed on a network where the clints have linked tables to the database on the server. I found that i had to make some minor changes to the tables on the server...
0
by: Wayne | last post by:
Can someone please help with this problem. When referring to opening a database in Exclusive mode the Access 2003 help says: "Under Default open mode, do one of the following: If you want others...
2
by: Javier Gomez | last post by:
How to open a linked table in exclusive mode from a FORM in DAO ??? (but,...... please I need it in DAO.) Thank you ! Javier Gomez
2
by: Gayathri | last post by:
Hi I am using MS Access to store the data in an .mdb file. And I observe that, if the .mdb is open, I receive a runtime error whenever I/someone tries to access any of the .aspx pages that needs to...
2
by: Mat | last post by:
Or how to check if it's open in exclusive mode...? Thx
6
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I...
1
by: buclas | last post by:
Hi, I need to link a mdb file and make sure it opens in a non-exclusive mode. I looked for a similar post but none was answered. I know there is a specific param to add to the command line to...
0
by: Salad | last post by:
A97. Split database. Frontend DB1.MDB. Backend DB1BE.MDB. Tables are linked between DB1 and DB2. From my testing, if I open DB1 exclusively using /excl the backend DB1BE is not opened...
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
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
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
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
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...

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.