WP7 Read Xml Writing in IsolatedStorage

I am new to WP7. I followed this tutorial to read and write an xml file, but when I read an xml file, it only shows the top line of the xml file. I do not know how to check the weather, the xml file is written correctly by the program. So.

1. Where can I check the xml files stored in isolated storage.

2. How to get rid of this problem.

My code for writing an Xml file in isolated storage:

      using (IsolatedStorageFile myIsolatedStorage =     
                            IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("mz1.xml", FileMode.Create, myIsolatedStorage))
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                using (XmlWriter writer = XmlWriter.Create(isoStream, settings))
                {
                    writer.WriteStartDocument();

                    writer.WriteStartElement("person");
                    writer.WriteElementString("node1", "value1");
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Flush();
                }
            }
        }

Code for reading an Xml file from isolated storage:

          using (IsolatedStorageFile myIsolatedStorage =          
                               IsolatedStorageFile.GetUserStoreForApplication())
            {
                IsolatedStorageFileStream isoFileStream =  
                         myIsolatedStorage.OpenFile("mz1.xml", FileMode.Open);
                using (StreamReader reader = new StreamReader(isoFileStream))
                {
                    textBlock1.Text= reader.ReadToEnd();
                }
            }

Conclusion:

     <?xml version="1.0" encoding="utf-8"?>
+5
source share
3 answers

In response to your first question, you can download and install the isolated WP7 Explorer from the code: http://wp7explorer.codeplex.com/

. app.xaml.cs, .

, , , . WP7, . :

public List<Task> GetTasks()
{
    var tasks = new List<Task>();
    using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (store.FileExists(XmlFile))
        {
            //store.DeleteFile(XmlFile);
            //XDocument doc = XDocument.Load(store.OpenFile(XmlFile, FileMode.Open));
            using (var sr = new StreamReader(new IsolatedStorageFileStream(XmlFile, FileMode.Open, store)))
            {
                XDocument doc = XDocument.Load(sr);
                tasks = (from d in doc.Descendants("task")
                         select new Task
                                    {
                                        Category = (string) d.Attribute("category"),
                                        Id = (string) d.Attribute("id"),
                                        Name = (string) d.Element("name"),
                                        CreateDate = (DateTime) d.Element("createdate"),
                                        DueDate = (DateTime) d.Element("duedate"),
                                        IsComplete = (bool) d.Element("isComplete")
                                    }).ToList<Task>();
            }
        }
    }
    return tasks;
}

, LinqToXml. .

, :

http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-2/

. , .

+6

. , TextBlock, , :

<?xml version="1.0" encoding="utf-8"?>
<person>
  <node1>value1</node1>
</person>

, TextBlock .

+2
+1

All Articles