You need to set the
"FileLeafRef" field of the underlying
SPListItem for the publishing page. You need to first check out the file (or create it and then Update it for new sites), update the
.ListItem["FileLeafRef"] property and then check it back in and publish it.
This code is to create a new publishing page and then change the file name. You have to run the
.Update on the PublishingPage before setting the FileLeafRef otherwise you get an
"object does not exist" error.
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(curWeb);
PublishingPage pubPage = pubWeb.AddPublishingPage();
pubPage.Title = "My New Page Title";
pubPage.ListItem["FileLeafRef"] = "default"; //.aspx is added automatically
pubPage.ListItem.SystemUpdate(); //SystemUpdate doesn't update the modified fields
Update: BaseName changed to FileLeafRef, BaseName is readonly and we can't update this field.