add

Monday, March 9, 2009

How to customization status of a file, removing any customization

Hi ,

This post deals with checking the customization status of any sharepoint file and if file is found to be customized then to remove its customiztion and reverting back to template file.




using System;
using Microsoft.SharePoint;
namespace CustomizationCheck {
class Program {
static void Main (string[] args) {
using (SPSite siteCollection = new SPSite("http://sitename")) {
using (SPWeb site = siteCollection.RootWeb) {
SPFile file = site.GetFile("default.aspx");
// if file is customized, revert to underlying template file
if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
file.RevertContentStream();
} // SPWeb using statement
} // SPSite using statement
} // method “Main”
}
}

No comments: