Thursday, July 23, 2009

Finding Customized pages

Scenario:
Upgrade is always painful, I was working on one site which has been used from a long time and I wanted to get an idea on to what level pages has been customized pages before I try to upgrade my site definition.

Solution:
Wrote a small utility to go through all the available pages. You can use the vti_hasdefaultcontent field obtained through the Properties property of the SPFile class to determine whether a file is customized.

Code:

SPFile file = SPContext.Current.Web.RootFolder.Files["default.aspx"];
bool IsCustomized = (bool)file.Properties["vti_hasdefaultcontent"];
Article:
MSDN

2 comments:

cool007 August 25, 2009 at 2:56 PM  

Does your post has a typo about term Ghosted?
My understanding -
Ghosted means uncustomized and they reside on file system.
UnGhosted means customized and they reside in content Database.

Is this correct?

Sandeep K Nahta August 25, 2009 at 4:47 PM  

You are right.. I corrected it