Rename a File in a SharePoint document library through object model
Following code will do that functionality. Like how we are renaming a file through UI, we have to first check-out the file and after renaming the file we have to check-in it.
<code>
SPSite oSite = new SPSite ("https://<sitename>/");
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["Shared Documents"];
SPListItem oListItem = oList.Items[0]; //taking the first list item
oListItem.File.CheckOut();
oListItem["Name"] = "xyz";
oListItem.Update();
oListItem.File.CheckIn("file name has been changed");
</code>