How to check in c# code if LocalDB currently installed? also, how to check if SQLNCLI11 presents in system?
How to check in c# code if LocalDB currently installed? also, how to check if SQLNCLI11 presents in system?
I'm using the answer to this question
to check for the existence of sqllocaldb.exe
Like so:
public static bool IsLocalDBInstalled()
{
return ExistsOnPath("SqlLocalDB.exe"); ;
}
public static bool ExistsOnPath(string fileName)
{
return GetFullPath(fileName) != null;
}
public static string GetFullPath(string fileName)
{
if (File.Exists(fileName))
return Path.GetFullPath(fileName);
var values = Environment.GetEnvironmentVariable("PATH");
foreach (var path in values.Split(';'))
{
var fullPath = Path.Combine(path, fileName);
if (File.Exists(fullPath))
return fullPath;
}
return null;
}
I found this nuget package that wraps up working with SQLLocalDB Has the following command
SqlLocalDbApi.IsLocalDBInstalled()