Wednesday, January 14, 2009

SPFile.MoveTo() not triggering alerts in doc library

SPFile.MoveTo(), at first glance, looks to be a very straightforward method where a file can be moved from one folder to another.

Trying to use it and have an alert triggered by your newly copied file? Forget it.

MoveTo() copies the binary to the target library as expected, but fails to recreate the item metadata (created, modified, users, dates, etc.) and will not trigger the alerts that your users set up for the target library.

To work around this problem, you can create your own method that uses the SPFileCollection.Add(), which allows you to specify metadata, as described here:

No comments: