473,396 Members | 1,918 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.

Access a file from a web page

I created a class that populates a bunch of its properties from an XML file
on the file system. I'm planning on using the class on a bunch of sites all
working off the same XML file. In testing the idea, it looks like if two
users open a page that accesses the file one user will be locked out of the
file.

Is this a case for threading? How can I make sure that any number of people
can access the XML file at the same time?

Thanks for any ideas.
Nov 16 '05 #1
3 1260
Hi,

Threading won't help you there since you seem to have locked the file.
Try reading the file without locking it, ie File.OpenRead or FileAccess
and FileShare set to Read

FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read,
FileShare.Read).
--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Thanks, I don't see a way to explicitly declare the file as "ReadOnly" using
the XmlTextReader, maybe it's the default? I'm starting to think maybe the
problem I had was not a file locking issue. This snippet is how I open the
file.
....
XmlTextReader xmlTextReader = new XmlTextReader(_appConfig);
xmlTextReader .Read();
while(xmlTextReader .Read()){
....

Thanks for your help!

"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opshepcsfaklbvpo@pbn_computer...
Hi,

Threading won't help you there since you seem to have locked the file.
Try reading the file without locking it, ie File.OpenRead or FileAccess
and FileShare set to Read

FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read,
FileShare.Read).
--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #3
I'm not familiar with XmlTextReader, but an option might be to read the
file into a MemoryStream and use that stream in the XmlTextReader
constructor.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
5
by: Fabio R. | last post by:
To support a webfarm scenario, I'd like to store a global array (serialized) in a file on a network share. In this array there is a list of pages "locked" by other users so I need to read this...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
1
by: igotyourdotnet | last post by:
Ok, here is the issue: I have 2 web pages one does a file upload to a database and the other page does a FTP to a server, both pages use the c:\temp directory. The page that uploads to a database...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
7
ADezii
by: ADezii | last post by:
There are essentially three techniques for publishing Access Data on the Web. The first technique is static, and does not allow for the dynamic addition or modification to the data, There is no...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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.