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

XDocument Exclusive Access

Tom
I can successfully do the following:

xdocument doc = xdocument.load(... my file);
xelement bla = doc.descendants.("it").first();
.... do stuff ...
doc.save("myfile");

the above works great. however, i want to interact with the file with
exclusive access so that no other files can open it/write to it/etc. while
i'm doing stuff with it.

i know that there's the normal FileStream.open (etc., fileshare.none), but
the xdocument class doesn't take a stream as a constructor.

is there any way i can do this without having to use the xmldocument class?

Thanks.

Oct 7 '08 #1
3 4411
Hi Tom,

For example like this XDocument.Load(new XmlTextReader(new FileStream .....

ps. mind 'using' statement

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
I can successfully do the following:

xdocument doc = xdocument.load(... my file);
xelement bla = doc.descendants.("it").first();
... do stuff ...
doc.save("myfile");
the above works great. however, i want to interact with the file with
exclusive access so that no other files can open it/write to it/etc.
while i'm doing stuff with it.

i know that there's the normal FileStream.open (etc., fileshare.none),
but the xdocument class doesn't take a stream as a constructor.

is there any way i can do this without having to use the xmldocument
class?

Oct 7 '08 #2
Tom
thanks alex,

that seems like the right idea, but it didn't seem to work. i get the
following exception:
"non white space characters cannot be added to content"

it looks like the constructor for the xdocument class can only take any of
the following:
1. nothing (e.g. - xdocument())
2. params object[] content
3. xdocument other
4. xdeclaration declaration, params object[] content

so i think when i try to use your example below, my guess is that it's
trying to add the new xmltextreader as content. any other ideas? i'll keep
playing with this one though.

thanks again.
-- tom
"Alex Meleta" <am*****@gmail.comwrote in message
news:df*************************@news.microsoft.co m...
Hi Tom,

For example like this XDocument.Load(new XmlTextReader(new FileStream
.....

ps. mind 'using' statement

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
>I can successfully do the following:

xdocument doc = xdocument.load(... my file);
xelement bla = doc.descendants.("it").first();
... do stuff ...
doc.save("myfile");
the above works great. however, i want to interact with the file with
exclusive access so that no other files can open it/write to it/etc.
while i'm doing stuff with it.

i know that there's the normal FileStream.open (etc., fileshare.none),
but the xdocument class doesn't take a stream as a constructor.

is there any way i can do this without having to use the xmldocument
class?

Oct 7 '08 #3
Tom
thanks alex. this actually worked like a charm. it's early, and i'm not
awake yet.
"Alex Meleta" <am*****@gmail.comwrote in message
news:df*************************@news.microsoft.co m...
Hi Tom,

For example like this XDocument.Load(new XmlTextReader(new FileStream
.....

ps. mind 'using' statement

Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
>I can successfully do the following:

xdocument doc = xdocument.load(... my file);
xelement bla = doc.descendants.("it").first();
... do stuff ...
doc.save("myfile");
the above works great. however, i want to interact with the file with
exclusive access so that no other files can open it/write to it/etc.
while i'm doing stuff with it.

i know that there's the normal FileStream.open (etc., fileshare.none),
but the xdocument class doesn't take a stream as a constructor.

is there any way i can do this without having to use the xmldocument
class?

Oct 7 '08 #4

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

Similar topics

1
by: Alan Jones | last post by:
Access 2000 onwards introduced a restriction that only allows you to edit and save forms, reports and macros when you have exclusive access to the database, i.e. no other user has the database...
1
by: JohnC | last post by:
I have this exact same scenario. It is new and seems to be related to when we installed Adobe 7.0 Standard/Professional. We have an MDB on a LAN file server. Using Access 2K and Windows 2K. ...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
0
by: MSDN | last post by:
Hi can anybody help me. I am trying to access a database I have created, using ADO. The code is fine but the Jet Engine returns an exclusive Access error Error tells me that the database is...
1
by: CJJ | last post by:
hi Folks, I am opening my access database file (Access 2003) from a C# application. The connection string specifies mode=Share Exclusive The intent is that the application have exclusive...
4
GrandMaster
by: GrandMaster | last post by:
Hi all When I used Access 97, I could edit reports and forms whilst other users had it open, the only problem was that the users had to close and reopen a form or report to see the form/report in...
1
by: PW | last post by:
Hi, All of a sudden one of our clients can't use her application. She gets "You don't have exclusive access to your database at this time" when trying to open our application. The only thing...
2
by: Zippy | last post by:
I recently updated one of my clients from Access 97 front-end to Access 2003. (Database still in 97 format). They have about 5 networked PCs. On one of these PCs only, the user gets a warning...
2
by: ARC | last post by:
Hello all, When a user starts my app, I run re-attaching code if the links are not valid, etc. In this routine, I then check the version of the back-end database. If the version is off, I run...
3
by: Tom | last post by:
I can successfully do the following: xdocument doc = xdocument.load(... my file); xelement bla = doc.descendants.("it").first(); .... do stuff ... doc.save("myfile"); the above works great. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.