Pages

Showing posts with label SPFile. Show all posts
Showing posts with label SPFile. Show all posts

Friday, May 29, 2009

How to find page/site customization status – Part 2 – with the help of SharePoint object model

I know that if I find my required data/information from SharePoint database then there must be some way to find same thing from object model. So I started debugging SPFile object and tried to see what are the properties exposed by object model, but I didn’t see any properties from code, then I have found some hidden properties which match with ALLDOCS table schema, properties names are "vti_hasdefaultcontent", "vti_setuppath", so after using those hidden SPFile properties, I got my results which match with query results,

Example Code:



SPFile objFile;

string bDefaultContent = (string)objFile.Properties["vti_hasdefaultcontent"];

string strSetupPath = (string)objFile.Properties["vti_setuppath"];

if (strSetupPath == null && bDefaultContent == null)

{

//If code executed and comes into this loop then current Page/File status is customized

//then I can take objFile.File and objFile.URL values

}

Reference Links:



I have found one hidden property name from object model for checking page/site customization

http://stsadm.blogspot.com/2007/09/re-ghosting-pages.html

Hidden Property name from file object

http://www.eggheadcafe.com/conversation.aspx?messageid=29277607&threadid=29254168

Comments are always welcome!!!

Easiest way to find file extension from SPFile Object

We can pass SPFile.Name object into FileInfo Class and get the extension of file. It will returns “.ASPX” or “.HTML” file extension depending upon file object.

 Example Code:   

SPFile objFile;

string strFileExtension = new FileInfo(objFile.Name).Extension;