When I publish a file from code
byte[] fileBytes = objItem.File.OpenBinary();
string DestinationURL = string.Format(@"{0}/{1}", objDestinationFolder.Url, objItem.File.Name);
//Copy the file.
SPFile objDestinationFile = objDestinationFolder.Files.Add(DestinationURL, fileBytes, true);
objDestinationFile.Update();
objDestinationFile.Publish(string.Format("File Copied from {0}", objItem.Url));
I get an error message which says
You can only publish, unpublish documents in a minor version enabled list
I checked the permissions of the list and it has "Create major and minor (draft) versions" checked. Any ideas?
EDIT
If I check in the file by calling the CheckIn method
objDestinationFile.CheckIn(string.Format(@"File Copied from {0}/{1}", objItem.Web.Url, objItem.Url));
everything works fine