This function can copy a listitem from one list to another. After a little debugging and googling I noticed that the url field has to be the complete field. The target list can contain less or more columns, it just copies the they share. Very simple implementation:
SPListItem.Copy(SPContext.Current.Web.Url + "/" + doc.Url, _publicLibUrl +doc.Name);
I made the destinationurl of the library a public property of my webpart. So I can use the webpart on any site. I'm still trying to find out if there is a possibility to overwrite documents. At first site it looks impossible. Any help on this is welcome.(workaround below) It is no problem to copy the item from one site to another on the same server.
I do this at the end of my approval workflow. When the document is approved and published, I copy it to document library on an other site, where all users have read acces. Togehter with RMS we can lock the files completely. When a reviewer changes things in the document, users won't notice it. Only after final approval, the document will be copied to the public library. This creates a working version and a published version.
Added on 8/7/2008
So I found a workaround for the SPListItem.Copy overwrite problem. First I tried the SPFile.CoptTo. This can overwrite the file but cannot copy to another site. Then I tried the SPFileCollection, but there the overwrite problem arrose again. So now I created a simple workaround, because I don't need versions I look for and delete the file before I copy it. The versions are kept in the original library.
SPSite site = SPContext.Current.Site;
SPFile file = site.AllWebs[_sopSiteName].GetFile(_publicLibUrl + doc.Name);
if (file != null)
{
file.Delete();
}
SPListItem.Copy(SPContext.Current.Web.Url + "/" + doc.Url, _publicLibUrl +doc.Name);