tags:

views:

63

answers:

0

Hi I am using the following code to load a dataset from an xml file:

public static DataSet _Data;
    public static DataSet Data
    {
        get
        {
            string encFileName = @"\\Pc\D$\temp\DS.xml";
            try
            {
                if (_Data == null)
                {
                    _Data = new DataSet1();
                    if (!File.Exists(encFileName))//(!encFile.Exists)
                    {
                        File.Create(encFileName);
                    }
                    else
                    {

                        _Data.ReadXml(encFileName);
                    }
            }
            catch (Exception xcp)
            {

                throw new Exception("Data load issue.");

            }
            return _Data;
        }
    }

When saving here is how i am using code:

    private static void SaveDataInThread(string destFileName)
    {
        _Data.AcceptChanges();
                    string xmlFileName = Path.Combine(Path.GetDirectoryName(destFileName), Path.GetFileName(destFileName) + DateTime.Now.ToString().Replace(":", string.Empty).Replace(@"/","-") + ".xml");
        _Data.WriteXml(destFileName);

    }

My question here is about the AcceptChanges() method. Is this the right place to call this or do we need to call this after loading the dataset. Please advise. Thanks N