Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top