diff --git a/Explorer/ExploreForm.cs b/Explorer/ExploreForm.cs index 37d200e..bae3312 100644 --- a/Explorer/ExploreForm.cs +++ b/Explorer/ExploreForm.cs @@ -3323,27 +3323,40 @@ namespace CodeWalker favoritesToolStripMenuItem.DropDownItems.Add("-"); - XmlDocument xDoc = new XmlDocument(); - xDoc.Load(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml"); - XmlNodeList FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite"); - foreach (XmlNode FavNode in FavoriteNodes) + try { - AddFavoriteItem(FavNode.InnerText); + XmlDocument xDoc = new XmlDocument(); + xDoc.Load(Application.StartupPath + @"\Resources\Favorites.xml"); + XmlNodeList FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite"); + foreach (XmlNode FavNode in FavoriteNodes) + { + AddFavoriteItem(FavNode.InnerText); + } + } + catch + { + MessageBox.Show("Favorites.xml is missing from " + Application.StartupPath + @"\Resources", "Error"); } - } private void addToFavToolStripMenuItem_Click(object sender, EventArgs e) { if (LocationTextBox.Text != "") { - XmlDocument xDoc = new XmlDocument(); - xDoc.Load(Application.StartupPath + @"Resources\Favorites.xml"); - XmlNode FavToAdd = xDoc.CreateElement("Favorite"); - FavToAdd.InnerText = LocationTextBox.Text; - xDoc.DocumentElement.AppendChild(FavToAdd); - xDoc.Save(Application.StartupPath + @"Resources\Favorites.xml"); - LoadFavorites(); + try + { + XmlDocument xDoc = new XmlDocument(); + xDoc.Load(Application.StartupPath + @"\Resources\Favorites.xml"); + XmlNode FavToAdd = xDoc.CreateElement("Favorite"); + FavToAdd.InnerText = LocationTextBox.Text; + xDoc.DocumentElement.AppendChild(FavToAdd); + xDoc.Save(Application.StartupPath + @"\Resources\Favorites.xml"); + LoadFavorites(); + } + catch + { + MessageBox.Show("Favorites.xml is missing from " + Application.StartupPath + @"\Resources", "Error"); + } } else { diff --git a/Explorer/OrganizeFavorites.cs b/Explorer/OrganizeFavorites.cs index 8563eb7..02b6d82 100644 --- a/Explorer/OrganizeFavorites.cs +++ b/Explorer/OrganizeFavorites.cs @@ -28,15 +28,22 @@ namespace CodeWalker.Explorer private void Init() { - xDoc.Load(Application.StartupPath + @"Resources\Favorites.xml"); - FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite"); - Root = xDoc.DocumentElement; - foreach (XmlNode FavNode in FavoriteNodes) + try { - FavoritesTreeView.Nodes[0].Nodes.Add(FavNode.InnerText); - } + xDoc.Load(Application.StartupPath + @"\Resources\Favorites.xml"); + FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite"); + Root = xDoc.DocumentElement; + foreach (XmlNode FavNode in FavoriteNodes) + { + FavoritesTreeView.Nodes[0].Nodes.Add(FavNode.InnerText); + } - FavoritesTreeView.ExpandAll(); + FavoritesTreeView.ExpandAll(); + } + catch + { + MessageBox.Show("Favorites.xml is missing from " + Application.StartupPath + @"\Resources", "Error"); + } } private void ClearAllFavoritesButton_Click(object sender, EventArgs e) @@ -62,7 +69,7 @@ namespace CodeWalker.Explorer private void SaveButton_Click(object sender, EventArgs e) { - xDoc.Save(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml"); + xDoc.Save(Application.StartupPath + @"\Resources\Favorites.xml"); ExploreForm.LoadFavorites(); Close(); }