Updating SPWeb.RootFolder.WelcomePage not working!

I was recently trying to programmatically set the default (welcome) page of a team site, but my changes weren’t taking effect. As it turns out, this code:

contextWeb.RootFolder.WelcomePage = rootFolder.Name + "/" + wikiFileName;

Needs to be changed to work with a local copy of an SPFolder. I haven’t used reflector but, i am guessing that on the ‘getter’ for SPWeb.RootFolder we are given a complete new instance every time. So the code now needs to be this – (thanks SharePoint):

SPFolder folder = context.Web.RootFolder;
folder.WelcomePage = rootFolder.Name + "/" + wikiFileName;