Operation not permitted on IsolatedStorageFileStream: Visual Studio 2010 Express for Phone

不打扰是莪最后的温柔 提交于 2019-12-11 19:38:44

问题


I am having this error: "Operation not permitted on IsolatedStorageFileStream." I am using visual studio 2010 express for phone c#.

Here is my code:

        public void LoadData()
        {
           string xmlUrl = "http://datastore.unm.edu/events/events.xml";

        using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
        {

            using (var isoFileStream = new IsolatedStorageFileStream(xmlUrl, FileMode.Open, FileAccess.ReadWrite, FileShare.Read, storage))
            {
                using (XmlReader xreader = XmlReader.Create(isoFileStream))
                {

                }

            }

        }
        }

Thank you for your help! It's much appreciated.


回答1:


if you want to read a xml from the web you should use the WebClient class. WebClient provides common methods for sending data to and receiving data from a resource identified by a URI.

Here's a little example

   private WebClient webClient;

    public Example()
    {
        webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompleted);
        webClient.DownloadStringAsync(new Uri("http://datastore.unm.edu/events/events.xml", UriKind.Absolute));
    }

    private void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {

        XElement Xmlparse = XElement.Parse(e.Result);


    }

as you can see we use DownloadStringCompletedHandler that occurs when an asynchronous resource-download operation completes.

Finally to parse the XML you can use XElement class more informartion here



来源:https://stackoverflow.com/questions/19458514/operation-not-permitted-on-isolatedstoragefilestream-visual-studio-2010-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!