2

I am looking to read xml files using xmlreader without causing lock on the file. all my operations are read only

$reader= system.Xml.XmlReader]::Create($xmlfile)

whenever I use $reader.read() I can't seem to get another thread read the same file.. any help is much appreciated.

1 Answer 1

2

Read the file into a string, wrap the string in a StringReader and pass that to the XmlReader.Create method e.g.:

$str = Get-Content C:\temp\foo.xml -Raw
$stringReader = new-object system.io.stringreader $str
$xmlReader = [system.xml.xmlreader]::Create($stringReader)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.