SharePoint : Get file system path.

While developing solutions for SharePoint we sometimes need to deploy files to the file system (14 hive in SharePoint 2010). Suppose we have a file named NavigationMap.xml and we deploy it to LAYOUTS\NavigationWebpart\XML folder using SharePoint Mapped folder options. Now, inside the code we need to get hold of this Xml file. This can be done by using GetGenericSetupPath method of SPUtility class as shown below:

string layoutsLocation = SPUtility.GetGenericSetupPath("TEMPLATE\\LAYOUTS");

// Location of Xml file inside the Layouts folder
string xmlPath = layoutsLocation + "/NavigationWebpart/XML/NavigationMap.xml";
XElement doc = XElement.Load(xmlPath);
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts