Data at the root level is invalid. Line 1, position 1

v123shine

New Member
I am downloading a xml file from the internet and save it in isolated storage. If I try to read it I get an error: \[quote\] Data at the root level is invalid. Line 1, position 1.\[/quote\]\[code\]string tempUrl = "http://xxxxx.myfile.xml"; // changedWebClient client = new WebClient();client.OpenReadAsync(new Uri(tempUrl));client.OpenReadCompleted += new OpenReadCompletedEventHandler(delegate(object sender, OpenReadCompletedEventArgs e) {StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream("myfile.xml", FileMode.Create, FileAccess.Write, myIsolatedStorage)); writer.WriteLine(e.Result); writer.Close();});\[/code\]This is how I download and save the file...And I try to read it like that:\[code\]IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("myfile.xml", FileMode.Open, FileAccess.Read);XDocument xmlDoc = XDocument.Load(fileStream);\[/code\]This is where I get the error...I have no problem reading the same file without downloading and saving it to isolated storage... so there must be the fault.
 
Back
Top