不允许对独立存储文件流进行操作:Visual Studio 2010 Express for Phone [英] Operation not permitted on IsolatedStorageFileStream: Visual Studio 2010 Express for Phone
问题描述
我遇到此错误:不允许对隔离存储文件流进行操作."我正在将 Visual Studio 2010 express 用于手机 c#.
I am having this error: "Operation not permitted on IsolatedStorageFileStream." I am using visual studio 2010 express for phone c#.
这是我的代码:
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.
推荐答案
如果您想从 Web 读取 xml,您应该使用 WebClient 类.WebClient 提供了向由 URI 标识的资源发送数据和从其接收数据的常用方法.
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.
这是一个小例子
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);
}
如您所见,我们使用了在异步资源下载操作完成时发生的 DownloadStringCompletedHandler.
as you can see we use DownloadStringCompletedHandler that occurs when an asynchronous resource-download operation completes.
最后解析 XML,您可以使用 XElement 类更多信息在这里
Finally to parse the XML you can use XElement class more informartion here
这篇关于不允许对独立存储文件流进行操作:Visual Studio 2010 Express for Phone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!