Calling this successfully reverts/uncustomises/reghosts the file in question, although I did notice the version history accessible through the master page gallery remains as-is. Nevertheless, a change to the file system .aspx file after running this code is honoured by MOSS.
Here's the code I wrote to encapsulate that call (it's a bit rough but for a one-off excercise does the trick). I simply run this from a console application (which you can download from here).
// Wait for debugger to attach
Console.WriteLine ("Waiting for debugger to attach. Press any key to continue...");
const string FILE_PATH = "/_catalogs/masterpage/ThreeColumns.aspx";
using (SPSite site = new SPSite ("http://dev:30000/"))
using (SPWeb web = site.AllWebs ["/"])
SPFile file = web.GetFile (FILE_PATH);
Console.WriteLine ("File status before change: " +
if (file != null &&
file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
Console.WriteLine ("Reverting file...");
catch (Exception e)
Console.WriteLine ("File status after change: " +
Console.WriteLine ("Unable to retrieve file");
Very nice. Thanks for the posts. I am sure this will come in handy for me in the future...ReplyDelete
YOU R THE MAN!ReplyDelete
I happened to do the same thing accidentally to 1 of feature-ed layout and was worried there is no way back... Thank you thank you thank you.