Blogger :
ASP.NET Blogs
All posts :
All posts by ASP.NET Blogs
Category :
SharePoint
Blogged date : 2006 Nov 11
Information on SharePoint and the path where it manages its information can be found in the registry. For example the registry entry SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Location contains the path to the Web Server Extensions folder for SharePoint 2007, and SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Version contains the current version of SharePoint 2007. Yes I know, RTM is out, and I'm still running on Beta 2 TR:-(
I came accross the following code by Microsoft for getting the Features folder:
private string GetSharePointFeaturesDirectory()
{
string key = @"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0";
string name = "Location";
string featuresDir = String.Empty;
try
{
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(key);
string value = regKey.GetValue(name) as string;
regKey.Close();
featuresDir = Path.Combine(value, @"template\features");
}
catch (SecurityException)
{
featuresDir = String.Empty;
}
catch (ArgumentNullException)
{
featuresDir = String.Empty;
}
catch (ArgumentException)
{
featuresDir = String.Empty;
}
catch (ObjectDisposedException)
{
featuresDir = String.Empty;
}
catch (IOException)
{
featuresDir = String.Empty;
}
catch (UnauthorizedAccessException)
{
featuresDir = String.Empty;
}
return featuresDir;
}