Question

I need to access a remote Xml document from a WCF service. Right now I have:

XmlReader reader = XmlReader.Create("path");

But since the Xml doc is elsewhere on our network I need to give the XmlReader an absolute path, as opposed to having it look deeper in the project folder. How do I do this? I've found surprisingly little information about this. It seems like this should be a simple thing to do. Any help is appreciated!

Thanks

Was it helpful?

Solution

You can use overload that accepts Stream parameters as follows:

using (FileStream fileStream = new FileStream(@"\\computername\shared path"))
using (XmlReader reader = XmlReader.Create(fileStream))
{
    // perform your custom code with XmlReader
}

Please note that you need appropriate permission to open remote stream. In WCF service context you may need to use impersonation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top