コード例 #1
0
ファイル: xmlStore.cs プロジェクト: sjk7/DX90SDK
        public XmlDataStore()
        {
            // First try to find the default XML Schema
            string mediaFolder = DXUtil.GetDXSDKMediaPath();

            xmlDocumentLocation = mediaFolder + "dxmsgserver.xml";

            xmlDom = new XmlDocument();
            if (!System.IO.File.Exists(xmlDocumentLocation))
            {
                // We need to create our default schema
                MessageBox.Show("The default XML data structure could not be found.  We will create a new one.", "No default schema.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.CreateDefaultSchema();
            }
            try
            {
                // Well the file exists, try to load it, and throw an exception if you
                // don't like it
                xmlDom.Load(xmlDocumentLocation);
                if (xmlDom.ChildNodes.Count < 1)
                {
                    throw new Exception();
                }
            }
            catch
            {
                MessageBox.Show("There was an error trying to read the XML data.  We will create a new schema.", "No default schema.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.CreateDefaultSchema();
            }
            // No one can be logged on now, make sure everyone is marked offline
            MarkEveryoneOffline();
        }