XDocument Exclusive Access

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.

0
10/7/2008 1:54:30 AM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
1212 Views

Similar Articles

[PageSpeed] 11

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?


0
ameleta (7)
10/7/2008 3:00:58 AM
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" <ameleta@gmail.com> wrote in message 
news:df84a49fd0ce8caf69c4256c590@news.microsoft.com...
> 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?
>
> 

0
10/7/2008 12:12:07 PM
thanks alex.  this actually worked like a charm.  it's early, and i'm not 
awake yet.


"Alex Meleta" <ameleta@gmail.com> wrote in message 
news:df84a49fd0ce8caf69c4256c590@news.microsoft.com...
> 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?
>
> 

0
10/7/2008 12:25:05 PM
Reply:

Similar Artilces:

Internet access required for stencils/templates
Why doesn't Visio 2003 have as many stencils/templates available within the "local" install as earlier versions? I used Visio 2000 in the past and I have used the geographic map templates on a regular basis. However I have just installed Visio 2003 on my laptop and these templates and stencils are missing! I have discovered that I need to have access to the internet to "download" each stencils as I need it (not much use when you are using a laptop on the road). I have searched everywhere on the Microsoft website to try to find where to download the complete set of sten...

vbscript insert into access 2003 database with two different table
I am trying to insert data collected by WMI. Here is the script On Error Resume Next Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const ForReading = 1 'Create FSO Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create an environment for the script to work Set wshshell = WScript.CreateObject("WScript.Shell") 'Connection to the database Set cnn = CreateObject("ADODB.Connection") 'Connection to a Recordset Set objRecordSet = CreateObject("ADODB.Recordset") 'Opens the Database ...

Excel query to access database
Hi, Could you help me to find solution for my problem please? I’m not very good in Excel and Access but have to create Excel spread sheet which will take data from Access DB. I almost done it but have one problem which not able to find solution. When I create query in Excel using “Query Wizard” there is a step called “Filter Data”. I would like to use filter for the table like that: Company Name – equals – Contoso. My problem is that instead using “Contoso” I would like to take value from filed in Excel document (like $c$2). Is it possible? How to do this? Thank you ...

How to dispose a XDocument?
Hello, I am loading a few XDocuments to read, write, etc. After using the XDocument can't I dispose it? I think I should or not? I was looking for it and XDocument does not have a Dispose method. Thanks, Miguel On 14-03-2010 20:12, shapper wrote: > I am loading a few XDocuments to read, write, etc. > > After using the XDocument can't I dispose it? I think I should or not? > I was looking for it and XDocument does not have a Dispose method. There are no need for it. XDocument only contains some data structures in managed memory. And that can be GC&#...

Access to excel
I have exported and imported a data set from Access. Excel insists on adding decimal places and putting numbers in that do not exist in the Access data base. How do I stop this from occurring? Michael Excel cannot make these numbers up. The truth is probably... Access has a number formatted to two decimal places so you see 1.50 in Access where actually Access is holding 1.49567892 (or similar) and the formatting gets lost en route -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Michael Lyon" <lyonm@upstate.edu>...

Can Excel Work like Access
My Question is....Can Excel Work Like Access I need two people to be able to enter data into the same workbook a one time. I do not want to deal with the hassle of access and the fac that i do not have access on one computer, limits my options. thanks for any help you can send my way -- Bostick7 ----------------------------------------------------------------------- Bostick73's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1443 View this thread: http://www.excelforum.com/showthread.php?threadid=27221 In essence the answer to your question is Yes. Excel can ...

Accessing Multiple Databases
I have six different database that I want to have access to via one form. Is it possible to have one form with buttons to open each of my databases similar to a switchboard that gives me access to each object in the current database? If so how can I do it? Thanks very much. One approach would be to first link to the tables in all six dbs. Then your switchboard could set a form's ControlSource property to the table needed. By the way, are all six of these dbs essentially "identical" in structure? If so, why have six? Regards Jeff Boyce Microsoft Office/Access MVP &qu...

Exclusion dictionary for excel 2003
Hi all, is there any way of having an exclusion dictionary for excel 2003? Thanks, Try this http://word.mvps.org/FAQs/General/ExcludeWordFromDic.htm Raul Queiroga wrote: > Hi all, > is there any way of having an exclusion dictionary for excel 2003? > > Thanks, ...

ANN: DBForms from MS Access to ASP.NET + MS SQL v 1.0 released.
We are glad to announce the releases of our new product DBForms from MS Access to ASP.NET+MS SQL v.1.0.0. This tool allows you to convert mdb (Microsoft Access forms) to .aspx web pages + MS SQL back-end with AJAX support. Convert forms and their elements (Label, Image, OptionGroup, TextBox, ListBox, ComboBox, CommandBox and others) to Web page including element position, color pallet and fields type. Advanced customization options: - Rename caption forms - partial selection for database objects that will be converted. - detection of possible conversion errors at customization stage. Session...

access won't let me edit queries
I'm stumped. I've suddenly become unable to edit queries. I went in to make a simple change to a query I've changed before (as in yesterday...), and suddenly, I can add a new table to the query builder, but I can't drag a join to the table. SQL view shows the table has been recognized. So, I move on, and try to edit another query. I open it for design, and then try to add a field to an append query. No add'l tables, no new joins, just drag the field down to the list of fields, assigning it to a field within the appended table. No dice. drop-downs are empty. What...

Accessing the Money Database from eVB?
Is it possible? What I want is my budget that is on my PC on my PocketPC. I can write the eVB easy enough, but is there a way to access the Money database that is on the PocketPC? Thanks, -- David Lozzi Associated Business & Technology Group www.associatedbtg.com I should've known that....but I had a brain fart. ...

Access Icon
Hi, I've designed a mgnificent Access tool,i need only to change the program icon,meaning that i want to replace Access disinct icon (the key) with another one,is it possible? Take a look at the following posts http://groups.google.ca/group/microsoft.public.access.forms/browse_thread/thread/b6ddc91f12b96982/8b698b32f4130c4e http://groups.google.ca/group/microsoft.public.access.gettingstarted/browse_thread/thread/b4e835ff6b22f107/6cbdadc03542bce5 -- Hope this helps, Daniel Pineault "Pietro" wrote: > Hi, > > I've designed a mgnificent Access tool,i ne...

Access 97 to Access 2000 conversion error
Hello, After taking the appropriate steps to convert a security multi-user Access 97 database to Access 2000, the conversion was a success without errors. Though when running the application I encounter this error: The Microsoft Jet database engine could not find the object '~sq_ffrmBaseDataWindow'. Make sure the object exists and that you spell its name and the path name correctly. It appears when the Microsoft Jet database engine is attempting to find an object with a corrupt name. Though there is a form that exist with the name 'frmBaseDataWindow'. Any assistan...

Access the "automatically suggest a name to enter" data ?
When typing in a name in a new e-mail, Outlook automatically suggests a name to enter, and I like this. However, I have many in there that I would like to add to my contacts. At present I do not want to type in "a" and then sellect one, then add it to my Outlook contacts etc and then repeat all they way through to "Z" Other than doing this ONE at a time, is there another way? Thanks You can't even add them one at a time the way you suggest. You can only add your autocompletion cache to your Contacts using third party software. http://www.ingressor.com/deskt...

Opening Access without Menus displayed
Access 97 I have created a simple data lookup form for a customer to look up his own jobs in a shared database - there is only the one form in the mdb(e) that auto-opens on application startup. I have unchecked all the Startup functions etc. The program auto-opens the form okay but there is the default menu bar displayed across the top of the application window. The tool bars do not show. Is there a way to open the program and not show ANY menus as well? My form close event also quits the application. I intend to provide this as an mde. Any ideas gratefully appreciated Piri Piri wrote: &...

exclusion formula?
I'd like to know how to write a formula to pull out all the data from a cell that's NOT in a corresponding cell. For example: COL A COL B Charles Dickens Tale of Two Cities Charles Dickens Orson Scott Card Enders Game Orson Scott Card Column A has name sof authors & books. Column B has the author's name in it. Since Column A has no standardization of spacing, number of breaks in a name, etc., I can't seem to get a regular LEFT, FIND, or MID type function to work, but I'd like Column C to return all of the data in Column A that's NOT in...

CRM with Access 2003
1.) I am trying to create a contact database. What insights and processes do you recommend? 2.) Can I alter the Templates we recieve from the Microsoft website? 3.) Can we transfer contacts from Outlook and information from Excel into Access? a. If so, how? 4.) Can multiple users be on a specific contact at the same time? 5.) Can we interchangeably use different Microsoft Access versions after we create a database (i.e., open a database that was created on Access 2003 on Access 2007) ? 6.) Can we mail merge? Best way to Query? Do we need to set up any macros or filters? --...

Accessing email via OWA
We want to enable users to access their email remotely using OWA. We have a Watchguard Firebox 700 and I have configured an HTTP and HTTPS service using NAT to point to the Exchange server. It all seems to work fine but I sent an email off to Watchguard tech support to ask how secure the connection would be if we were not using VPN (as users may be connecting from their friend's PC's etc... which woul dnot have VPN connections setup...) The resonse I got from them was this.. "Assuming that your OWA IIS server is set up for SSL (certificate), then you should be all set." If...

conversion from Access 97
Good morning all - I am converting several databases from Access 97 to Access 2000. The smaller databases are working fine. However, I have a number of large databases that I have converted - queries on large tables in these databases are running very, very slowly since the conversion. These databases are connected to tables on an SQL server using ODBC. I use a calendar form so that the user can select dates - these are assiged to a VBA variable... These queries worked fine in Access 97 - maybe Access 2000 is handling the variables differently? The queries are so slow that ofte...

Can Access 2003 read and modify mdb files created by Access 2007
I have a MDB database file created under Access 2003 and is being used by several people over a Local network. One of the user has upgraded to Office 2007 and the remaining people stays with Access 2003. Can that Access 2007 user convert the A03 MDB files into an A07 MDB files and this new MDB be accessable and be modified by other users with A03. Thanks! Brian Brian <Brian@discussions.microsoft.com> wrote: >I have a MDB database file created under Access 2003 and is being used by >several people over a Local network. > >One of the user has upgraded to Office 2007 a...

accessing m_lpCmdLine (or GetCommandLine())
We have an MFC application that was converted to run as a DLL extension to another program. Instead of an MFC main loop we are using AFX_MANAGE_STATE(AfxGetStaticModuleState()); to hook up our MFC code to the new app. The problem is that now AfxGetApp()->m_lpCmdLine does not have the command line any more, just an empty string. Additionally (and I posted this part to win32.programmer.kernel as well) GetCommandLine() is not returning the command line string either -- instead, we get a buffer with each (incorrectly parsed) argument followed by a null terminator, and the last arg...

POP3 access
Hi, Up till now we have had a Linux POP3 server which collects outside mail and the internal Outlook clients retrieve those messages. With my new Exchange 2000 server I am planning to do away with the POP3 server and have messages forwarded directly to the Exchange server by the firewall. At present I have some accounts on the POP3 server which don't have a matching Exchange Mailbox. These are staff and directors who never work internally. They retrieve their mail by a POP3 client such as Outlook Express. I assume I will have to setup Mailboxes for these users under my new scenari...

MS Access 2007
Can you filter a crosstab in MSAccess using a Combo Box? Seems to error out everytime we try it. Thanks for your quick answer! First thing, with a crosstab query you MUST declare your parameters and if any other queries are used in the crosstab their parameters must also be declared. Open the query in design mode Select Query: Parameters from the Menu Fill in the EXACT name of the parameter in column 1 Select the data type of the parameter in column 2 John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County hfd wrote: >...

Access 2003-Access 2002 Incompatibility
I updated an Access 2002 db using Access 2003. Now when I try to run the db on Access 2002 I get an error message that says: Access contains a missing or broken reference to file msador15.dll version 2.7 What can I do to fix this problem? Or more generally, what do I do to ensure that dbs created or modified with Access 2003 will still run on Access 2002? Thanks. Have MDAC 2.7 been installed on the machine that's attempting to use the database? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Chaplain Doug" <anonymous@discussio...

problem sending Access data to Word MailMerge
Using Access 2003 the following code used to work. The user would click a button, Word and then the MailMerge original doc would open, and then the user would have to select which table in the database held their required data. The table was created in the code immediately preceding the MailMerge coding below, and the TableName is stored in the string field strTable. ++++ start of code Dim objWord As Word.Document Set objWord = GetObject(gstrMergeDocument_ACTION_PLAN, "Word.Document") objWord.Application.Visible = True ...