2010-11-22 80 views
1

我花了几个小时寻找如何做到这一点,不幸的是作为一个C#新手不能解决如何做到这一点,虽然我确信它很简单。我试图抓取我存储在XML中的数据并将其绑定到列表。我当前使用的是foreach方法,只是使用代码将项目添加到列表框中,但是当您想要像我一样存储时,这看起来效率低下并且有点笨拙。我正在使用以下代码从当前的IO中检索项目:用XML绑定数据linq

using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       foreach (string items in storage.GetFileNames("*.item")) 
       { 
         XElement _xml; 

         IsolatedStorageFileStream location = new IsolatedStorageFileStream(items, System.IO.FileMode.Open, storage); 

         System.IO.StreamReader file = new System.IO.StreamReader(location); 
         _xml = XElement.Parse(file.ReadToEnd()); 
         XAttribute att = _xml.Attribute("att"); 

在此先感谢!

回答