2
votes

I'm tring to obtain file path for sharepoint 2013 location without hardcoding values on code.

I found the method GetGenericSetupPath,SPUtility class, wich has a strange behaviuor:

SPUtility.GetGenericSetupPath("Template") 

reuturns

"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\Template"

on the 15 hive

inhstead

SPUtility.GetGenericSetupPath("template\\LAYOUTS")

return a path on 14 hive

"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\template\LAYOUTS"

finally the default path seems to be hive 15:

SPUtility.GetGenericSetupPath("")

"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\" string

1

1 Answers

4
votes

After some investigation i found this post:

The problem was that

SPUtility.GetGenericSetupPath Method IS OBSOLETE

and it returns a link to the 14 hive (SharePoint 2010), not the the new 15 hive (SharePoint 2013).

Instead of this we have to use SPUtility.GetVersionedGenericSetupPath(), where you can choose wich version of sharepoint use, so you can specify:

SPUtility.GetVersionedGenericSetupPath("TEMPLATE\\FEATURES", 15)