I used code (similar to the sample below) to do this. It checks to see if the file's parent list is the master page / page layout library.
Maybe you know a better way?
string url = " -- ABSOLUTE PATH TO YOUR FILE -- ";
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
SPList masterPagelist = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
SPFile file = web.GetFile(url);
if (file.Item.ParentList.ID == masterPagelist.ID)
{
// The file is in the master page library.
}
}
}
No comments:
Post a Comment