2007-06-19

SPListItem and the CopyTo method

Yes, I've struggled with identifying the format of the destination url when trying to copy a publishing page from one Pages list to another using the SPListItem.CopyTo method. Again, Reflector came to my rescue. Reflector showed that the Url must contain a page name as well - NOT only the path to the list. If the page doesn't exist it will be created.

Wrong url: http://myserver/site/pages
Correct url: http://myserver/site/pages/thepagename.aspx

Then it works as it should.

Knowing how the publishing process is in SharePoint it really shouldnæt be a surprise, but sometimes the ... brain cells ... seems to be a bit "off line" :-)

1 comment:

chris said...

Good morning,

I am having an issue with the ListItem.CopyTo method. I wish to copy calendar items from calendar to another on a different site.However I get this error:
"Source item cannot be found. Verify that the item exists and that you have permission to read it."
Any ideas will be greatly appreciated.

Thank you
Regards
Chris