XPathDocument Constructor
Hello everyone,
When use the following XPathDocument Constructor, we can not open the XML file in exclusive mode. Any ideas about how to open an XML file in exclusive mode and using XPath Query?
http://msdn.microsoft.com/en-us/libr...95(VS.80).aspx
thanks in advance,
George
Re: XPathDocument Constructor
The link you provided points to the constructor that takes a string parameter to the file path.
Now without giving you the answer directly, I ask you to determine if there are other XPathDocument constructors that you can use that will enable you to open a file with an exclusive lock and use one of these other constructors.
Re: XPathDocument Constructor
Thanks for your hint, Arjay!
I have written some code, could you review whether it is correct solution please? :-)
Code:
FileStream fs = new FileStream("foo.txt", FileMode.Open, FileAccess.Read, FileShare.None);
XPathDocument xp = new XPathDocument(fs);
Quote:
Originally Posted by Arjay
The link you provided points to the constructor that takes a string parameter to the file path.
Now without giving you the answer directly, I ask you to determine if there are other XPathDocument constructors that you can use that will enable you to open a file with an exclusive lock and use one of these other constructors.
regards,
George
Re: XPathDocument Constructor
Quote:
Originally Posted by George2
Thanks for your hint, Arjay!
I have written some code, could you review whether it is correct solution please? :-)
Code:
FileStream fs = new FileStream("foo.txt", FileMode.Open, FileAccess.Read, FileShare.None);
XPathDocument xp = new XPathDocument(fs);
regards,
George
C'mon George, don't ask for this. Test the code yourself. (Hint: use the forum when you've exhausted all the other options).