Пример #1
0
        public static void importXML(String path, string fileName)
        {
            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(Game));
                using (var sr = new StreamReader(path))
                {
                    Game importedGame = (Game)xs.Deserialize(sr);

                    importedGame.Id       = null;
                    importedGame.GameName = fileName;

                    int?id = DB_Insert.InsertGame(importedGame);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("This file is not in the correct format for this game. The game cannot be imported", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Console.WriteLine(ex.ToString());
            }
        }
Пример #2
0
 //creating the new blank game in the db can take a few seconds, so do it in a background thread
 private void bwInsertGame_DoWork(object sender, DoWorkEventArgs e)
 {
     DB_Insert.InsertGame(newGame);
 }