Added Try/Catch to prevent crashing if "Favorites.xml" cant be found

This commit is contained in:
FiftyShadesOfBlue 2018-03-16 02:37:48 -04:00
parent ba199212a6
commit d86255de58
2 changed files with 3 additions and 3 deletions

View File

@ -3338,11 +3338,11 @@ namespace CodeWalker
if (LocationTextBox.Text != "")
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml");
xDoc.Load(Application.StartupPath + @"Resources\Favorites.xml");
XmlNode FavToAdd = xDoc.CreateElement("Favorite");
FavToAdd.InnerText = LocationTextBox.Text;
xDoc.DocumentElement.AppendChild(FavToAdd);
xDoc.Save(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml");
xDoc.Save(Application.StartupPath + @"Resources\Favorites.xml");
LoadFavorites();
}
else

View File

@ -28,7 +28,7 @@ namespace CodeWalker.Explorer
private void Init()
{
xDoc.Load(@"C:\Users\Skyler\Documents\GitHub\CodeWalker\Resources\Favorites.xml");
xDoc.Load(Application.StartupPath + @"Resources\Favorites.xml");
FavoriteNodes = xDoc.DocumentElement.SelectNodes("Favorite");
Root = xDoc.DocumentElement;
foreach (XmlNode FavNode in FavoriteNodes)