add api to check if spotify is installed (#193)

This commit is contained in:
Ferdin Handoko 2017-11-10 03:37:10 +13:00 committed by Jonas Dellinger
parent a70bc5fc09
commit 26b5f8054d

View File

@ -302,6 +302,31 @@ namespace SpotifyAPI.Local
return Process.GetProcessesByName("spotifywebhelper").Length >= 1; return Process.GetProcessesByName("spotifywebhelper").Length >= 1;
} }
/// <summary>
/// Determines whether [spotify is installed].
/// </summary>
/// <returns>
/// <c>true</c> if [spotify is installed]; otherwise, <c>false</c>.
/// </returns>
public static bool IsSpotifyInstalled()
{
bool isInstalled = false;
// Checks if UWP Spotify is installed.
string uwpSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0");
isInstalled = Directory.Exists(uwpSpotifyPath);
// If UWP Spotify is not installed, try look for desktop version
if (!isInstalled)
{
string desktopSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Spotify\Spotify.exe");
isInstalled = File.Exists(desktopSpotifyPath);
}
return isInstalled;
}
/// <summary> /// <summary>
/// Runs Spotify /// Runs Spotify
/// </summary> /// </summary>