• Coding
  • windows mobile programming

Hey there i'm developing an windows mobile application about a clothes store , which i'm using an isolated storage to store and retrieve data from an xml files as a database , the application is reading the xml files correctly which manipulation is going well but the problem that i'm facing that when i want to save the modified data back to the xml file it doesn't save,the xml file remain unchanged,with no error in the code.
so any suggestions ?
Show us some code if you want us to help.
alright i'm using c# language and silverlight WM 7.1
in my app there's a customer class which contains the following code
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;
namespace WindowsPhoneApplication1
{
    public class customer
    {
       
        public string Name { get; set; }
        public string Password { get; set; }

         public customer(string Name, string Password)
        {
            this.Name = Name;
            this.Password =Password;
        }
         public customer(XElement xElement)
        {
            Name = xElement.Element("Name").Value;
            Password = xElement.Element("Password").Value;
        }
         public XElement Information
         {
             get
             {
                 return new XElement("customer",
                         new XElement("Name", Name),
                         new XElement("Password",Password));
             }
         }
    }
}
and a customerlist class which contains the following code
using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Xml.Linq;
using System.IO;
using System.Xml;
using System.IO.IsolatedStorage;

namespace WindowsPhoneApplication1
{
    public class customerlist : List<customer>
    {
        public void Load(string strXMLFile)
        {
            IsolatedStorageFile isfData = IsolatedStorageFile.GetUserStoreForApplication();
            XDocument doc = null;
            IsolatedStorageFileStream isfStream = null;
            if (isfData.FileExists(strXMLFile))
            {
                isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.Open, isfData);
                doc = XDocument.Load(isfStream);
                isfStream.Close();
            }
            else
            {
                doc = XDocument.Load(strXMLFile);
                isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.CreateNew, isfData);
                doc.Save(isfStream);
                isfStream.Close();
            }


            var vCustomer = from c in doc.Descendants("customer")
                          select new customer(c);
            this.Clear();
            AddRange(vCustomer);
        }
        public void Save(string strXMLFile)
        {
            try
            {
                XElement xml = new XElement("customer",
                                from p in this
                                select p.Information);
                IsolatedStorageFile isfData = IsolatedStorageFile.GetUserStoreForApplication();
                IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.Open,isfData);
                xml.Save(isfStream);
                isfStream.Close();
                isfStream.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
and the database "database.xml" contains
<?xml version="1.0" encoding="utf-8" ?>
<customers>
  <customer>
    <Name>admin</Name>
    <Password>123</Password>
  </customer>
</customers>
in the application page i just make a simple code to test if the adding is going well
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using System.Xml;
using System.Xml.Linq;

namespace WindowsPhoneApplication1
{
    public partial class adduser : PhoneApplicationPage
    {
        customerlist m_dbList;
        public adduser()
        {
 m_dbList = new customerlist();
 m_dbList.Load("Database.xml");
 m_dbList.Add(new customer("user","456"));
 m_dbList.Save("database.xml");
}
}
}
the new customer is now added correctly to the list and the list must be saved to the xml file with the "save" function , so after closing the app i go back and open the xml file , which i see no changing take place,and i don't know why?
so any help
do you have permission to write into the file? maybe its locked
i read some books about windows phone programming they didn't mention that !!