XDocument, FileStream and UNC Paths

We moved two servers yesterday that were originally part of a Windows domain. At the new place the domain would no longer exist (we also transffered ownership) so we removed the machines from the domain and set them to be part of a standard workgroup. For the most part this worked accept there was one application that was pulling XML files from one machine to another using UNC paths and standard FileStreams. ASP.Net was throwing an IOException of Logon failure: unknown user name or bad password. Makes sense, the FileStream call wasn’t doing any type of authentication and to the best of my knowledge, there’s no way to specify any credentials (short of using unmanaged code). I started to think of ways around this. In the past I had played with AppDomains which allowed me to reset the credentials but I remember that opened up a whole other can of worms. Then I realized that I was just using the FileStream to give me a String that I was passing to XDocument.Parse(). Well, XDocument also has a Load() method which takes a URL. So, a quick easy solution was to map the UNC path in IIS as a virtual folder, specify the credentials for the remote machine and then use the XDocument.Load() method to load the data. If the document wasn’t an XML document I could have used the same process except use the WebClient instead (Dim S = New System.Net.WebClient().DownloadString("http://..."))