473,395 Members | 1,418 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,395 software developers and data experts.

Locking File

Hello,

I am opening a file like below:
FileStream fs =
File.Open(Server.MapPath("../Data/REFCOD.txt"),FileMode.Open,FileAccess.Writ
e,FileShare.None);

---------------------------------------------------------
I do not want anyone to access the file while it is opened.
---------------------------------------------------------
My question is:
If another request tries to open this file while it is opened will the
request wait untill it can open it and then proceed with its operation or
will an exception be generated?

I'm hopeing that it will wait untill it can open it and then will.
If not is there a way todo so with out generating an exception?
Thanks,
Ron Vecchi
Nov 17 '05 #1
2 1436
execption thrown

"Ron Vecchi" <ve******@comcast.net> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
Hello,

I am opening a file like below:
FileStream fs =
File.Open(Server.MapPath("../Data/REFCOD.txt"),FileMode.Open,FileAccess.Writ e,FileShare.None);

---------------------------------------------------------
I do not want anyone to access the file while it is opened.
---------------------------------------------------------
My question is:
If another request tries to open this file while it is opened will the
request wait untill it can open it and then proceed with its operation or
will an exception be generated?

I'm hopeing that it will wait untill it can open it and then will.
If not is there a way todo so with out generating an exception?
Thanks,
Ron Vecchi

Nov 17 '05 #2
Rats,

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
execption thrown

"Ron Vecchi" <ve******@comcast.net> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl...
Hello,

I am opening a file like below:
FileStream fs =

File.Open(Server.MapPath("../Data/REFCOD.txt"),FileMode.Open,FileAccess.Writ
e,FileShare.None);

---------------------------------------------------------
I do not want anyone to access the file while it is opened.
---------------------------------------------------------
My question is:
If another request tries to open this file while it is opened will the
request wait untill it can open it and then proceed with its operation or will an exception be generated?

I'm hopeing that it will wait untill it can open it and then will.
If not is there a way todo so with out generating an exception?
Thanks,
Ron Vecchi


Nov 17 '05 #3

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

Similar topics

2
by: Geoffrey | last post by:
We have developed a python class that can read data files created from another application. These target files are C-ISAM files used for accounting applications so the "primary" application may be...
2
by: Kamus of Kadizhar | last post by:
Thanks to Robert Brewer, I got enough insight into logging to make it work.... Now I have another issue: file locking. Sorry if this is a very basic question, but I can't find a handy reference...
2
by: Scott Bryce | last post by:
I am creating a CGI application in Perl that uses an Access database. It will be hosted on an NT server. I have used flat file DBMs (tied hashes) on UNIX servers, but I am not familiar with how...
4
by: darrel | last post by:
I've been dealing with a file locking issue for a while. Our CMS spits out a new XML file each time an item in the DB is updated. This XML file is basically our site menu, and is what we use on...
3
by: dchadha | last post by:
Hi, I am working on application in C# which uses and stores data in xml file. This app can use xml file from two different ways: (a) From User Interface (Windows application) and (b) From...
5
by: Adrian | last post by:
Is there a way to lock records and/or files in multi user application, using C#? Adrian.
5
by: JM | last post by:
I have created a Windows Service which uses xml file as a data source. The service is running on .NET 2.0 and uses LocalSystem account. It was running fine but now it has started locking the xml...
15
by: Matt Brandt | last post by:
I am trying to get multiple threads to lock specific regions of a file. However, since each thread has the same PID, it appears that a lock by one thread does not block another thread from the same...
2
by: Sparky | last post by:
Hello! I am writing some software that will have many users accessing the same file resource at once for reading purposes only. I am programming on (Ubuntu) Linux and my question is in Windows, can...
9
by: zmickle | last post by:
Experts and books all say that you can share an Access back end on a shared drive with the front end running on each host computer. I have a simple database that tracks student data and it is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.