Browse Source

Create Playlists directory if it does not exist.

Stephen Damm 6 years ago
parent
commit
544ecaee7a
1 changed files with 7 additions and 6 deletions
  1. 7 6
      SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

+ 7 - 6
SongBrowserPlugin/DataAccess/SongBrowserSettings.cs

@@ -154,6 +154,13 @@ namespace SongBrowserPlugin.DataAccess
                 retVal = new SongBrowserSettings();
             }
 
+            // check if the playlist directory exists, make it otherwise.
+            String playlistDirPath = Path.Combine(Environment.CurrentDirectory, "Playlists");
+            if (!Directory.Exists(playlistDirPath))
+            {
+                Directory.CreateDirectory(playlistDirPath);
+            }
+
             // Load Downloader favorites but only once, we'll convert them once, empty the song_browser_setting.xml favorites and never load it again.
             String playlistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName);
             if (!File.Exists(playlistPath))
@@ -191,7 +198,6 @@ namespace SongBrowserPlugin.DataAccess
 
             // check if the playlist exists
             String playlistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName);
-
             bool playlistExists = false;
             if (File.Exists(playlistPath))
             {
@@ -308,11 +314,6 @@ namespace SongBrowserPlugin.DataAccess
                     SettingsSerializer.Serialize(writer, this);
                 }
             }
-
-            /*FileStream fs = new FileStream(SongBrowserSettings.SettingsPath(), FileMode.Create, FileAccess.Write);            
-            XmlSerializer serializer = new XmlSerializer(typeof(SongBrowserSettings));           
-            serializer.Serialize(fs, this);            
-            fs.Close();*/
         }
     }
 }